vendredi 20 janvier 2017

Getting the value of a local Field at run time

I am really new to c# and I just want to know if it is possible to get the value of a locally declared field at runtime?

example:

public class ClassToTest {
  public void func() {
    int number = 25;
  }
}

Public class MyProgram {
  public static void Main() {
    ClassToTest instance = new ClassToTest();
    instance.func();
    // Can field "number" value be extracted here?
  }
}

I have been looking through reflection and other assembly related stuff but still no luck. Any suggestions will highly be appreciated.





Aucun commentaire:

Enregistrer un commentaire