E
Earl Teigrob
In the exampe below, the constructor of the container class is passed the
string called "foo". Within the container class, I would like to create an
instance(s) of foo and add them to the ArrayList that is returned. (Once I
figure this out I will use reflection on the instance to do other stuff)
Anyway, How to I dyanamically create a new instance of a class from
ClassName string?
Thanks for your Help
Earl
private void Button1_Click(object sender, System.EventArgs e)
{
container mycontainer = new container("foo");
ArrayList fooArrayList = mycontainer.GetListOfObjects();
}
public class container
{
public string ClassName;
public container(object ClassName)
{
this.ClassName=ClassName;
}
public ArrayList GetListOfObjects()
{
ArrayList myArrayList = new ArrayList();
for(int i=1;i<10;i++)
{
//Convert.ToClass(ClassName) myClass = new Convert.ToClass(ClassName)
//myArrayList.Add(myClass);
}
return myArrayList;
}
}
public class foo
{
public string a="ahhhh";
public string b="bee";
public string c="see";
}
}
string called "foo". Within the container class, I would like to create an
instance(s) of foo and add them to the ArrayList that is returned. (Once I
figure this out I will use reflection on the instance to do other stuff)
Anyway, How to I dyanamically create a new instance of a class from
ClassName string?
Thanks for your Help
Earl
private void Button1_Click(object sender, System.EventArgs e)
{
container mycontainer = new container("foo");
ArrayList fooArrayList = mycontainer.GetListOfObjects();
}
public class container
{
public string ClassName;
public container(object ClassName)
{
this.ClassName=ClassName;
}
public ArrayList GetListOfObjects()
{
ArrayList myArrayList = new ArrayList();
for(int i=1;i<10;i++)
{
//Convert.ToClass(ClassName) myClass = new Convert.ToClass(ClassName)
//myArrayList.Add(myClass);
}
return myArrayList;
}
}
public class foo
{
public string a="ahhhh";
public string b="bee";
public string c="see";
}
}