struct Point { public int x, y; public Point(int x, int y) { this.x = x; this.y = y; } }the code fragment
Point a = new Point(10, 10); Point b = a; a.x = 100; System.Console.WriteLine(b.x);outputs the value 10. The assignment of a to b creates a copy of the value, and b is thus unaffected by the assignment to a.x. Had Point instead been declared as a class, the output would be 100 because a and b would reference the same object. end example]
| |
Jagger Software Ltd | |
Company # 4070126 | |
VAT # 762 5213 42 |