0
Reply

creating the instance of a class with the name as the value of any other variable

ravi asrani

ravi asrani

Feb 15 2006 7:39 AM
1.5k

Hello all,

                 I am working with the reflection and i am trying to find out a solution which can lead to some easier method.

          I just wanted to ask that is it possible to create an instance of an object with its name as the value of anyother variable.

                If Yes then please tell me about that.

I have tried for setting the name property afterwards but that is not enough for the requirement.

I have tried as follows :

System.Windows.Forms.TextBox t = new TextBox();

string s = "txtName";

t.Name = s;

but that will not refer to the original object t.

it will just show the name property as the value of the variable s.

but i want to create the object at the time of the its instance.

like

System.Windows.Forms.TextBox (Here i want the value of the variable) = new TextBox();

Please reply if u know the answer.