In this example, we use Activator.CreateInstance to create an instance of MyClass . We then cast the instance to MyClass and call a method on it.
In this example, we use Activator.CreateInstance to create an instance of MyClass , passing arguments to the constructor. c# activator
object instance = Activator.CreateInstance(typeof(MyClass), new object[] { "Hello", 42 }); Use code with caution. In this example, we use Activator