Excecuting a statment that is in a string

  • Thread starter Thread starter brunie
  • Start date Start date
B

brunie

Hello,

I have following :

string ClassName = "Client";
string Command = ClassName + ".GetType()";

Now I have a statement in a string.
How can I excecute the statement that is in that string?

Is something like this possible in C# and how?

Type t = Excecute(Command);

Thanks
 
brunie said:
I have following :

string ClassName = "Client";
string Command = ClassName + ".GetType()";

Now I have a statement in a string.
How can I excecute the statement that is in that string?

Is something like this possible in C# and how?

Type t = Excecute(Command);

See my recent post on the other thread you started - you don't need to
do this. (Note that you wouldn't be able to do it with the above
anyway, as GetType() is an instance method, not a static method.)
 
Back
Top