日期:2014-05-17  浏览次数:20904 次

C#面向对象问题,根据类中的属性定位到所属的类,动态实例化
    public class A
    {
        public string A_property1 { set; get; }
        public string A_property2 { set; get; }
        public B b1;
        public B b2;
    }
    public class B
    {
        public string B_property1 { set; get; }
        public string B_property2 { set; get; }
    }

给出如上的类,现在欲向B的属性B_property1中填充数据,因为想做到通用性,所以采用动态实例化,我怎么才能从属性名字定位到类B,然后再由类B推出类A,然后再进行动态实例化?

------解决方案--------------------
好像很厉害。。帮顶
------解决方案--------------------
多看看设计模式吧。