Reflection
In this chapter you will learn:
Get to know Reflection
Runtime type ID lets we identify a type during the code execution. Reflection enables you to obtain information about a type.
An instance of System.Type
represents the metadata for a type.
Type
Represents type declarations:
class types, interface types, array types, value types,
enumeration types, type parameters, generic type
definitions, and open or closed constructed generic types.
You can get an instance of a System.Type
by calling GetType
on any object or with C#'s
typeof
operator:
System.Type is derived from an abstract class called System.Reflection.MemberInfo. MemberInfo defines the following abstract, read-only properties:
Return Type | Method Name | Meanings |
---|---|---|
Type | DeclaringType | The type of the class or interface in which the member is declared. |
MemberTypes | MemberType | The type of the member. |
string | Name | The name of the type. |
Type | ReflectedType | The type of the object being reflected. |
MemberTypes is an enumeration:
- MemberTypes.Constructor
- MemberTypes.Method
- MemberTypes.Field
- MemberTypes.Event
- MemberTypes.Property
Next chapter...
What you will learn in the next chapter:
Home » C# Tutorial » Reflection