This tutorial demonstrates how to go get class’s property value and invoke class’s method with Reflection.

Reflection provides objects (of type Type) that encapsulate assemblies, modules and types. You can use reflection to dynamically create an instance of a type, bind the type to an existing object, or get the type from an existing object and invoke its methods or access its fields and properties. If you are using attributes in your code, Reflection enables you to access them.
First, you will need to import the System. Reflection namespace

The System.Reflection namespace contains classes and interfaces that provide a managed view of loaded types, methods, and fields, with the ability to dynamically create and invoke types.
We use btnGetProperty_Click to get the property value of the class InstanceClass. And we use btnInvoke_Click to invoke the function getFunction of the class InstanceClass. The code as follows.

Add one custom class InstanceClass in this example.The code as follows:

The front end ReflectionCsharp.aspx page looks something like this:

The flow for the code behind page is as follows.

Download Source Files