Hi, given a name of an class e.g. "MyClass" which is stored as a string
is it possible to create a new instance of this type dynamically and
then reference the attributes by name in code??
e.g.
If my class is called Person and it has attributes FirstName and
LastName is it possible to do something like this;
public void GeneratePerson( )
{
string className = "Person";
(CreateInstance OfPerson) _person = new (CreateInstance OfPerson);
_person.FirstNa me = "fred";
_person.LastNam e = "smith";
_person.AddName ();
}
I did look at using reflection but can't seem to create an instance of
an object just given a string and then populate the object with
attrbutes.
Any help appreciated
Thanks
Markus
=============== ========
googlenews2006m arkusj
is it possible to create a new instance of this type dynamically and
then reference the attributes by name in code??
e.g.
If my class is called Person and it has attributes FirstName and
LastName is it possible to do something like this;
public void GeneratePerson( )
{
string className = "Person";
(CreateInstance OfPerson) _person = new (CreateInstance OfPerson);
_person.FirstNa me = "fred";
_person.LastNam e = "smith";
_person.AddName ();
}
I did look at using reflection but can't seem to create an instance of
an object just given a string and then populate the object with
attrbutes.
Any help appreciated
Thanks
Markus
=============== ========
googlenews2006m arkusj
Comment