声明一个结构体类型的Point
1 public struct Point 2 { 3 private int x; 4 private int y; 5 public Point(int _x, int _y) 6 { 7 this.x = _x; 8 this.y = _y; 9 } 10 public void Change(int _x, int _y) 11 { 12 this.x = _x; 13 this.y = _y; 14 } 15 public override string ToString() 16 { 17 return string.Format("({0},{1})", this.x, this.y); 18 } 19 }
2、分布采取不同的操作后,会在控制台输出什么内容?
1 Point p = new Point(1, 1); 2 Console.WriteLine(p); 3 4 p.Change(2, 2); 5 Console.WriteLine(p); 6 7 object o = p; 8 Console.WriteLine(o); 9 10 ((Point)o).Change(3, 3); 11 Console.WriteLine(o);
一只甜甜圈
森林海
忽然笑
胡说叔叔
相关分类