Dynamically invoking constructors : Constructor : Reflection C# Examples


C# Examples » Reflection » Constructor »

 

Dynamically invoking constructors









    
using  System;
using  System.Collections.Generic;
using  System.Text;
using  System.Threading;
using  System.Reflection;
using  System.Reflection.Emit;

public  class  MainClass
{
        public  static  void  Main()
        {
                ConstructorInfo  ci  =  typeof(string).GetConstructor(new  Type[]  {  typeof(char[])  });
                string  s  =  (string)ci.Invoke(new  object[]  {new  char[]  {  'H',  'e',  'l',  'l',  'o'  }  });
                Console.WriteLine(s);
        }
}
    
   
  
   



Output

Hello


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Reflection
» Constructor