Wednesday, April 20, 2011

Get Value from Variable inside Variable.

public class Utils
  public static object MyEvaluate(string eval, object source)
    return source.GetType().GetField(eval,
      BindingFlags.IgnoreCase | BindingFlags.NonPublic | 
      BindingFlags.Instance | BindingFlags.Public)
Then you'll have to call it like this instead:
private int A;

// initialize it in the declarations or elsewhere
this.A = 10;
string B = "A";
var C = Utils.MyEvaluate(B, this);

No comments:

Post a Comment