public class a{
public int b;
public bool c;
}我如何使用映射,来设置这个a类里面的公有变量。然后获取到这个a类,去使用。??

解决方案 »

  1.   

    是反射吧?
    类a的实例.GetType().GetProperty("b").SetValue
    还有 GetType().GetProperties获得多个属性,自己看帮助
      

  2.   

    public int _b;
    public int b{get{return _b;} set{_b=value;}};
    ---------------------------------------------------
    a a1 = new a();a1.GetType().GetField("_b").SetValue(a1,2)
    a1.GetType().GetProperty("b").SetValue(a1,2)
      

  3.   

    如果要用这样的方式Type t = typeof(a);我这样的话,如何获取这个a呢?