Dynamically creating a object

  • Thread starter Thread starter Vannela
  • Start date Start date
V

Vannela

In my unmanaged there is code i n this way

Class1 c1= new Class1(); // Class1 is one
object and creating a instance of it\

Class1 c2= new Class2();// Class2 is another object a
c2 is its instance

string s=c2.f1().GetDataCollection(); //GetDatacolection
gets some object name

c1=new s; // this is creating a object dynamically

Can we achieve this concept in C#?
Please send me some code snippets

Thank you
 
Think this shud work:
object o = Activator.CreateInstanceFrom("SampleAssembly.dll",
"SampleNamespace.SampleClass");

HTH
Krishnan
 
Back
Top