using System; class MyClass { [MyAttribute] public void MyMethod() { } } // ... var myObject = new MyClass(); var hasAttribute = Attribute.IsDefined(myObject.GetType().GetMethod("MyMethod"), typeof(MyAttribute)); Console.WriteLine(hasAttribute); // Output: TrueIn this example, we have a class called "MyClass" with a method called "MyMethod" that has the custom "MyAttribute" attribute applied to it. We then create an instance of the MyClass and use the System HasAttribute method to check if the attribute is present. The System HasAttribute method is part of the System.Reflection namespace in the standard .NET Framework library.