M
MarkusJNZ
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";
(CreateInstanceOfPerson) _person = new (CreateInstanceOfPerson);
_person.FirstName = "fred";
_person.LastName = "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
=======================
googlenews2006markusj
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";
(CreateInstanceOfPerson) _person = new (CreateInstanceOfPerson);
_person.FirstName = "fred";
_person.LastName = "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
=======================
googlenews2006markusj