[C#][PPC]how can I use CompilerServices with CF (not supported) ?

G

Guest

Hi,

I'd like to use System.Runtime.CompilerServices with the Compact framework
because I want to execute code which is in a string like that :

int i = 0;
string action = "i = 2;";
????.Execute(action);
Console.Writeline ("La valeur de i est: " + i);

In the compact framwork, System.Runtime.CompilerServices is not supported.

Somebody knows a solution ?

Thanks.

Best Regards.
 
P

Peter Foot [MVP]

How much flexibility do you need? if you just need to set the value from a
string use:-
string val = "2"; //perhaps this comes from a data file etc

int i = 0;

i = Integer.Parse(val);

Console.Writeline ("La valeur de i est: " + i);

If you have a finite number of operators you could write code in a switch
block so depending on the contents of your string e.g. "+=", "=", "-=". If
you also need to be able to specify which value you are modifying at runtime
you can do this too using reflection. use GetType on your object, and call
GetField with the parsed name, then SetValue. You will need to wrap in a try
catch block in case you specify a field name "x" which doesn't exist.

Peter
 
G

Guest

Thanks Peter. It's ok.
In fact, in my compagny, we develps a project which allows create forms
dynamics since a file xml, like xaml. the project is almost finished.

Another question : do you have a date for Smart device framework 1.3 ?

Thanks.

Best regards.
 

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

Top