C# Type CustomAttributes

In this chapter you will learn:

  1. Get to know Type.CustomAttributes
  2. Syntax for Type.CustomAttributes
  3. Example - Type.CustomAttributes

Description

Type CustomAttributes gets a collection that contains this member's custom attributes.

Syntax

Type.CustomAttributes has the following syntax.


public virtual IEnumerable<CustomAttributeData> CustomAttributes { get; }

Example


using System;//  w  w w . ja v  a2  s.co  m

public class MyClass1
{
   public void MyMethod1()
   {
   }
}
    
class MyGetTypeFromCLSID
{

    public static void Main()
    {
        Type myType = typeof(MyClass1);
        Guid myGuid =(Guid) myType.GUID;
        Console.WriteLine(myType.ToString());
        Console.WriteLine(myType.CustomAttributes);        
    }
}

Next chapter...

What you will learn in the next chapter:

  1. Get to know Type.DeclaringMethod
  2. Syntax for Type.DeclaringMethod
  3. Example - Type.DeclaringMethod