新手学c#,下面的代码在vs2005中编译不能通过,但是代码是从出版社下载的,不知道是怎么回事,麻烦看看。
public class Point
{
public int X = 1;
public int Y = 2;
}
class Program
{
static void Main()
{
Point pt1 = new Point();
Point pt2 = new Point { X = 5,Y = 6};//此处报错
Console.WriteLine( "pt1: {0}, {1}", pt1.X, pt1.Y );
Console.WriteLine( "pt2: {0}, {1}", pt2.X, pt2.Y );
Console.ReadKey();
}
}
}