public class TouchableArea {
public Rect rect;
public Rect Rect{
get{return rect;}
set{rect = value;}
}
}
以上是我的课。 Rect
是一个结构体,并具有设置新值的功能Set
。当我使用属性来设置一个新的值直到什么都不会发生,但是当我直接使用矩形时,一切都很好。无法通过C#中的属性调用函数?
TouchableArea t = new TouchableArea();
t.Rect.Set(newValue);//Through property, nothing happens
t.rect.Set(newValue);//Directly access, it works.
这是否意味着通过属性调用函数是非法的?
请参阅:[为什么可变结构邪恶?](http://stackoverflow.com/questions/441309/why-are-mutable-structs-vil) – Ani 2012-04-23 03:11:37
@Ani我认为你需要说明 – Baz1nga 2012-04-23 03:13:31