G
Guest
Hello, I want to dynamically create an object based on it's type. The core if
it sould be to use Activator.CreateInstance. This works fin for its,
floats..., but not for strings. Here's a sample:
string s;
s= "1020";
Type t = s.GetType();
object o = Activator.CreateInstance(t);
An exceptin is thrown saying: "No parameterless constructor defined for this
object.".
Please help!
it sould be to use Activator.CreateInstance. This works fin for its,
floats..., but not for strings. Here's a sample:
string s;
s= "1020";
Type t = s.GetType();
object o = Activator.CreateInstance(t);
An exceptin is thrown saying: "No parameterless constructor defined for this
object.".
Please help!