首页上一页 1 下一页尾页 3 条记录 1/1页
Struct
发表在C#图书答疑
2013-12-09
是否精华
是
否
版块置顶:
是
否
public struct Point
{
private int xCoord;
private int yCoord;
public Point(int x, int y)
{
xCoord = x;
yCoord = y;
}
public int x
{
get { return xCoord; }
set { xCoord = value; }
}
public int y
{
get { return xCoord; }
set { xCoord = value; }
}
}
再在Void main()中添加下列代码,
Point p1 = new Point(100, 100);
Point p2 = new Point();
p2.x = 50;
p2.y = 75;
Console.WriteLine("The x Coordination of P1 is {0}", P1.xCoord);
Console.WriteLine("The y Coordination of P1 is {0}", P1.yCoord);
Console.WriteLine("The x Coordination of P2 is {0}", P2.xCoord);
Console.WriteLine("The y Coordination of P2 is {0}", P2.yCoord);
为何第三个输出值不是75?
谢谢
{
private int xCoord;
private int yCoord;
public Point(int x, int y)
{
xCoord = x;
yCoord = y;
}
public int x
{
get { return xCoord; }
set { xCoord = value; }
}
public int y
{
get { return xCoord; }
set { xCoord = value; }
}
}
再在Void main()中添加下列代码,
Point p1 = new Point(100, 100);
Point p2 = new Point();
p2.x = 50;
p2.y = 75;
Console.WriteLine("The x Coordination of P1 is {0}", P1.xCoord);
Console.WriteLine("The y Coordination of P1 is {0}", P1.yCoord);
Console.WriteLine("The x Coordination of P2 is {0}", P2.xCoord);
Console.WriteLine("The y Coordination of P2 is {0}", P2.yCoord);
为何第三个输出值不是75?
谢谢