Reflection

Reflection refers to the ability to retrieve information about objects at runtime. This information can include the class that an object belongs to, the methods that belong to the object, and the constructors of the object.

Note

It is possible to retrieve Runtime Type Information (RTTI) in C++ as well. However, this enables you to find only the type of the object. Reflection in C# retrieves more detailed information. Reflection in C# is very useful in automatic software testing programs.

The namespace that is used in reflection is the System.Reflection namespace. You can use either the typeof operator or the GetType() method to get a Type object. The typeof operator is used to retrieve a class name. On the other hand, the GetType() ...

Get Special Edition Using C# 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.