create instance of object using reflection
Published: 13. December 2008 | Updated: 13. December 2008License: Microsoft Public License (MS-PL)
Categories: Framework » Reflection
Tags: C# Reflection
Short example how to create instance to specified type with parameters in constructor
Type type = typeof(Exception); string parameter = "my exception"; Exception ex = Activator.CreateInstance(type, parameter) as Exception; Console.WriteLine(ex.Message);Console Output:
my exception
| Send us feedback about this snippet » |





