1 class Program 2 { 3 struct student 4 { 5 public int num; 6 public string name; 7 public string sex; 8 public one oone; 9 public int[] qq; 10 } 11 12 struct one 13 { 14 public string aa; 15 public int bb; 16 } 17 static void Main(string[] args) 18 { 19 ////struct 20 ////初始化结构体 21 //student stu = new student(); 22 //stu.num = 1; 23 //stu.name = "张三"; 24 //stu.sex = "男"; 25 //student stu2 = new student(); 26 //stu2.num = 2; 27 //stu2.name = "李四"; 28 //stu2.sex = "女"; 29 ////stu和stu2并没有什么关系 结构体可以说是另一种数据的存储方式 30 31 32 33 ////结构体内嵌套结构体 34 //student stu = new student(); 35 //stu.oone.aa = "123"; 36 //stu.oone.bb = 123456; 37 //stu.qq = new int[10];//不初始化也可以,但是习惯初始化一下 38 Console.ReadLine(); 39 } 40 }