C#中结构体struct与类类似,但他是轻量级的,不能拥有方法,下面是简单的使用演示
using System; struct Person { public string name; public int age; public double height; } class TestStructureType { public static void Main () { Person p; p.name ="mani"; p.age = 24; p.height = 5.5; Console.WriteLine("Person Name: " + p.name); Console.WriteLine("Person Age: " + p.age ); Console.WriteLine("Height: "+ p.height); } }
附件:源代码下载