B
bowser
Hello, I have a problem with reflection. I posted it already a month
ago, but I had no luck with the answers...
Having two variables:
Type t;
string id;
initialized for example as t="Foo" and id="foo"
I need to make the equivalent of :
Foo foo = new Foo();
meaning, something like:
t id = new t();
(but obviously this is incorrect since id is a string and t is a
variable and can't be used for this purpose in this way).
I know how to instantiate the new object:
ConstructorInfo ci = t.GetConstructor(new Type[] { });
object obj = ci.Invoke(null);
But I need to assign name and type to it.
How can I do?
Thank you.
Alesssandro
ago, but I had no luck with the answers...
Having two variables:
Type t;
string id;
initialized for example as t="Foo" and id="foo"
I need to make the equivalent of :
Foo foo = new Foo();
meaning, something like:
t id = new t();
(but obviously this is incorrect since id is a string and t is a
variable and can't be used for this purpose in this way).
I know how to instantiate the new object:
ConstructorInfo ci = t.GetConstructor(new Type[] { });
object obj = ci.Invoke(null);
But I need to assign name and type to it.
How can I do?
Thank you.
Alesssandro