function eval

  • Thread starter Thread starter KaHuNa
  • Start date Start date
K

KaHuNa

What is the equivalent in c# for

var st = eval("myArray."+myOtherArray[0]);

to get a string. Thanks
 
Hi,

I am not sure what do you want to do. I you want construct and execute code
on the fly, there is no equivalent, but you can take a look at the
System.Reflection.Emit namespace and at the Microsoft.CSharp namespace.
 
What is the equivalent in c# for

var st = eval("myArray."+myOtherArray[0]);

to get a string. Thanks

Well, seeing as there hasn't been any other replies yet, I'll give it a
shot (though I'm not sure what the eval is supposed to do)

string st = "myArray." + (string)myOtherArray[0];
 
exactly i read a file text an i want to take all the variables separately.
I have wrote in my TextFile like that: var1="abc"&var2="123".

Dmitriy Lapshin said:
Hi,

I am not sure what do you want to do. I you want construct and execute code
on the fly, there is no equivalent, but you can take a look at the
System.Reflection.Emit namespace and at the Microsoft.CSharp namespace.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

KaHuNa said:
What is the equivalent in c# for

var st = eval("myArray."+myOtherArray[0]);

to get a string. Thanks
 
eval like this name says it, evaluate the string.

Exemple:
string a = "var1=123";
eval(a); give

var1 = 123


"Morten Wennevik" <[email protected]> a écrit dans le message de
What is the equivalent in c# for

var st = eval("myArray."+myOtherArray[0]);

to get a string. Thanks

Well, seeing as there hasn't been any other replies yet, I'll give it a
shot (though I'm not sure what the eval is supposed to do)

string st = "myArray." + (string)myOtherArray[0];
 
If var1, var2 etc. are class fields, you can probably parse the input file
manually and set values of the fields through means provided in the
System.Reflection namespace.
 
Back
Top