Yes it is possible.
To create an instance that you would use:
Type classType = Type.GetType("TestClass"); object instance = Activator.CreateInstance(classType);
And then calling Sub(23, 42)
on instance
looks like this:
classType.InvokeMember("Sub", BindingFlags.InvokeMethod, null, instance, new object[] { 23, 42 });
Reflection is used (for example) when you do not know the types at compile time and want to detect them at runtime (for example, in external dlls, plugins, etc.).
source share