日期:2014-05-17 浏览次数:21026 次
class A
{
public int Value { get; set; }
}
class B
{
public A Obj { get; private set; }
public B()
{
this.Obj = new A() { Value = 1 };
}
}
class Program
{
static void Main(string[] args)
{
B a = new B();
a.Obj.Value = 2; //怎样才能让这步不被允许?A是dll中的类,不能修改。只能改B和Program。
}
}
class TestClass { public string Name { get; set; } }
class Decorator<T> where T :class
{
private T obj;
public Decorator(T value)
{
this.obj = value;
}
public object GetProperty(string propertyName)
{