我想知道是否不可能设置访问器以允许您访问访问器的变量。错误示例:
public void Main()
{
Object.name = "test"; //Can't access the object's subproperties
}
Objec ob = new Objec();
public Objec Object
{
get { return ob; }
set { ob = value; }
}
class Objec
{
string name;
string value;
}
无论如何都可以做上述事情(除了为每个值制作访问器)?
谢谢,
马克斯
编辑:这是一个更好的例子
public void Main()
{
//Now I can't change the X or Y properties, this will display an error
ThePoint.X = 10;
//To change the x value, I need to do the following:
ThePoint = new Point(10,0);
}
private Point Poi = new Point();
public Point ThePoint
{
get { return Poi; }
set { Poi = value; }
}
有没有办法让“ThePoint.X”工作(不只是公开显示“Poi”)?