class MyClas
{
public System.Windows.Point p;
public void f()
{
p.X = 0;
}
}
此代码完美运行。
同时这会导致编译错误(“Cannot modify the return value of p, because it is not a variable”):
class MyClas
{
public System.Windows.Point p {get; set;}
public void f()
{
p.X = 0;
}
}
有什么不同?