用于一次性存储不同类型的变量
public Struct 结构名{
成员;//字段
}
变量在运行期间只可以存储一个值,而字段可存储多个值;
namespace 结构练习 { public struct MyColor { public int _red; public int _green; public int _yellow; } public struct Person { public string _name; public int _age; public Gender _gender;//枚举类型 } public enum Gender { 男, 女 } class Program { static void Main(string[] args) { MyColor color; color._red = 255; color._green = 0; color._yellow = 0; Person zsPreson; Person xlPerson; zsPreson._name = "张三"; zsPreson._age = 17; zsPreson._gender = Gender.男; xlPerson._name = "小兰"; xlPerson._age = 15; xlPerson._gender = Gender.女; Console.ReadKey(); } } }