Search This Blog

Tuesday, January 10, 2012

C# Using reflection to create an instance of a specific type; convert string to a specific type;

The idea behind the post is to convert a string such as: “System.Int32” to an instance of a specific type.
To create an instance of a compiled custom class in the assembly:

Assembly.GetExecutingAssembly().CreateInstance(YourCustomClassName);

To create an instance of a built-in type e.g. “System.Int32” :
Activator.CreateInstance(Type.GetType("System.Int32"));

1 comment:

  1. We have now started providing bulk SMS API C# India that is very powerful and easy to integrate into your own software/application/website. As it saves your lot of valuable time in logging our interface again and again.

    ReplyDelete

If you like this post, please leave a comment :)