日期:2014-05-17 浏览次数:21117 次
public class Car
{
    private int height;
    [ReadOnly(true)]
    public int Height 
    { 
    get;set;
    }
}
        Car car = new Car();
        car.GetType().GetProperty("Height").SetValue(car, 100,null); //ok
------解决方案--------------------
属性是肯定不可以的。
调用只读属性的SetValue会抛出异常
字段就不知道了。。你可以试试
------解决方案--------------------