title: Is it possible to dynamically compile and execute C# code fragments within the context of a object/method?
body: <p>This is an extension of this question: <a href="https://stackoverflow.com/questions/826398/is-it-possible-to-dynamically-compile-and-execute-c-sharp-code-fragments">Is it possible to dynamically compile and execute C# code fragments?</a></p>
  
  <p>But is it possible to reference fields, properties and methods of a certain object? For example:</p>
  
  <pre><code>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
      }
  }
  </code></pre>
  
  <p>The code obviously makes no sense in terms of functionality, but it's just an example.</p>