This is an extension of this question: Is it possible to dynamically compile and execute C# code fragments?
But is it possible to reference fields, properties and methods of a certain object? For example:
public class SomeClass
{
public int a, b;
public int SomeMethod(int a, int b, int c)
{
return a + b + c;
}
public void Execute()
{
int c = 3;
string code = "a = b = 2; int result = SomeMethod(a, b, c);";
// Compile and execute code here
}
}
The code obviously makes no sense in terms of functionality, but it's just an example.