Dynamically creating a object

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Vannela

    #1

    Dynamically creating a object

    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().GetDa taCollection(); //GetDatacolectio n
    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


  • Krishnan

    #2
    Re: Dynamically creating a object

    Think this shud work:
    object o = Activator.Creat eInstanceFrom(" SampleAssembly. dll",
    "SampleNamespac e.SampleClass") ;

    HTH
    Krishnan
    "Vannela" <anonymous@disc ussions.microso ft.com> wrote in message
    news:d8a401c3bb 24$e8c112d0$a60 1280a@phx.gbl.. .[color=blue]
    > 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().GetDa taCollection(); //GetDatacolectio n
    > 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
    >
    >[/color]


    Comment

    Working...