e心e意

导航

C#结构

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();
}
}
}

posted on 2014-11-25 17:20  e心e意  阅读(266)  评论(0编辑  收藏  举报