fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. public class Test
  5. {
  6. public static void Main() {
  7. var list = new List<Point>();
  8. list.Add(new Point(10, 20));
  9. list.Add(new Point(20, 40));
  10. list.Add(new Point(40, 80));
  11.  
  12. list[1].X = 30;
  13.  
  14. foreach(var pt in list) {
  15. Console.WriteLine(pt);
  16. }
  17. }
  18.  
  19. class Point {
  20.  
  21. public int X { get; set; }
  22. public int Y { get; set; }
  23.  
  24. public Point(int x, int y) {
  25. X = x;
  26. Y = y;
  27. }
  28.  
  29. public override String ToString() {
  30. return String.Format("X = {0}, Y = {1}", X, Y);
  31. }
  32. }
  33. }
Success #stdin #stdout 0.04s 24264KB
stdin
1
2
10
42
11
stdout
X = 10, Y = 20
X = 30, Y = 40
X = 40, Y = 80