Appendix X Reflection
A class’s type provides properties and methods that provide a wealth of information about the class. You can get a Type
object representing a class by using typeof(TheClass)
or by calling the GetType
method on an instance of the class.
The following section summarizes the Type
class’s most useful properties and methods. The sections after that summarize other useful reflection classes.
Type
The following table lists the Type
class’s most useful properties.
Property | Description |
Assembly | Gets the assembly where the type is declared. |
Attributes | Gets the type’s attributes. |
BaseType | Gets the type’s parent class. |
ContainsGenericParameters | Indicates whether the type has generic type parameters. |
CustomAttributes | Gets the type’s custom attributes. |
FullName | Gets the type’s fully qualified name, which includes the type’s namespace but not its assembly. |
IsAbstract | Returns true if the type is abstract. |
IsArray | Returns true if the type is an array. |
IsAutoLayout | Returns true if the type’s fields are laid out automatically by the CLR. |
IsByRef | Returns true if the type is passed by reference. |
IsClass | Returns true if the type is a class. |
IsCOMObject | Returns true if the type is a COM object. |
IsEnum | Returns true if the type is an enumeration. |
IsExplicitLayout | Returns true if the type’s fields are laid out explicitly. |
IsGenericType | Gets a value indicating whether the current type is a generic type. |
IsImport | Returns true if the type was imported from a COM library. |
IsInterface ... |
Get C# 5.0 Programmer's Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.