現在我們把前面用到的Point類應用進來,比如:
static void Main()
{
List<Point> myPointList = new List<Point>
{
new Point {X = 10, Y = 20},
new Point {X = 100, Y = 200},
new Point {X = 1000, Y = 2000}
};
foreach (var p in myPointList)
{
Console.WriteLine(p);
}
}
程序運行結果如下:
[10,20,Color=白色]
[100,200,Color=白色]
[1000,2000,Color=白色]