//结构体:定义一组变量 struct student { public int number; public string name; public string sex; public one xx; } struct one { public string aa; public int bb; } //枚举类型:定义一个常量 enum meiju { one = 3, //不是赋值,是指向索引,3号索引是one two = 6, //6号索引是two这个常量 three, four = two //逗号可以省略,若一个常量等于之前的一个常量,那么就等于这个常量 } enum meiju1 { one = 3, two = 6, three, four = three } static void Main(string[] args) { //初始化结构体 student stu = new student(); stu.number = 1; stu.name = "张三"; stu.sex = "男"; student stu1 = new student(); stu1.number = 2; stu1.name = "李四"; stu1.sex = "女"; Console.ReadLine(); student stu2 = new student(); stu2.xx.aa = "123"; stu2.xx.bb = 123; Console.ReadLine(); Console.WriteLine(meiju.one); Console.WriteLine(meiju1.four); Console.ReadLine(); }
时间: 2024-10-04 22:23:22