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.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top