我有一个名为 BaseRobot
的类:
var robot2 = new BaseRobot(0, 0, 0);
private Point mHome;
public Point Home
{
get { return mHome; }
}
这是创建原始主页的位置,我想在program.cs
中创建一个新主页。我有以下代码,但它不起作用,出现错误信息:
无法修改返回值,因为它不是一个变量。
代码:
robot2.Home.X = 1
robot2.Home.Y = 5;
{
Console.WriteLine("===New robot at specified home position===");
StringBuilder ab = new StringBuilder();
ab.AppendFormat("Robot#2 has home at <{0},{0}>.\r\n ", robot2.Home.X, robot2.Home.Y);
ab.AppendFormat("It is facing {0} ", robot2.Orientation);
ab.AppendFormat("and is currently at <{0},{0}>.\r\n", robot2.Position.X, robot2.Position.Y);
Console.WriteLine(ab.ToString());
}
如何为x和Y分配新值?
Point
的声明和命名空间是什么? - H H