关于结构和类
using System;class C1
{
public string Name;
public string ID;
public string Name1;
public int Age;
}
class C2
{
public static void Main()
{
C1 c = new C1();
c.Name = "heng yi zi xun";
c.ID = "001";
c.Name1 = "wangqiang";
c.Age = 20;
Console.WriteLine(" gong si ming cheng{0}",c.Name);
Console.WriteLine(" yuan gong dai ma{0}",c.ID);
Console.WriteLine(" yuan gong ming cheng{0}",c.Name1);
Console.WriteLine(" yuan gong nian ling{0}",c.Age);
}
}
using System;
struct C1
{
public string Name;
public string ID;
public string Name1;
public int Age;
}
class C2
{
public static void Main()
{
C1 c;
c.Name = "heng yi zi xun";
c.ID = "001";
c.Name1 = "wang qiang ";
c.Age = 20;
Console.WriteLine(" gong si ming cheng{0}",c.Name);
Console.WriteLine(" yuan gong dai ma{0}",c.ID);
Console.WriteLine(" yuan gong ming cheng{0}",c.Name1);
Console.WriteLine(" yuan gong nian ling{0}",c.Age);
}
}
以上两个程序的区别在哪里,我看没有什么区别,好像是访问上的区别,请详细指点一下。谢谢