namespace STRUCT_TEST{class PRogram{struct A{public int X;//不能直接对其进行赋值public int Y;public static string str = null;//静态变量可以初始化public A(int X, int Y)//带参数的构造函数{this.X = X;this.Y = Y;Console.WriteLine("X={0},Y={1},str={2}",X ,Y ,str );}}static void Main(string[] args){A a = new A(1, 2);A a1 = a;a.X = 10;Console.WriteLine("a1.X={0}",a1 .X );Console.Read();}}}
新闻热点
疑难解答