标签:int pac col names text system read span reading
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace _26对象数组 8 { 9 class Program 10 { 11 static void Main(string[] args) 12 { 13 // -------------------------------- 常规的数组类型-------------------------------- 14 string name = "张三"; 15 string[] names = new string[] { "张三", "李四", "王五" }; 16 int[] ages = new int[] { 12, 15, 23 }; 17 // -------------------------------- 对象数组 -------------------------------- 18 Student[] students = new Student[30]; 19 // --------------------------------学生1 20 Student stu1 = new Student(); 21 stu1.StuName = "张三"; 22 stu1.ClassName = "一年级"; 23 stu1.Age = 14; 24 stu1.StuNum = "S12090414"; 25 // --------------------------------学生2 26 Student stu2 = new Student(); 27 stu2.StuName = "李四"; 28 stu2.ClassName = "二年级"; 29 stu2.Age = 20; 30 stu2.StuNum = "22090414"; 31 // -------------------------------- 将学生放置于数组之中 32 students[0] = stu1; 33 students[1] = stu2; 34 35 // -------------------------------- 学生数组的打印 36 for (int i = 0; i < students.Length; i++) 37 { 38 Console.WriteLine($"{students[i].StuName}的年龄是{students[i].Age},在{students[i].ClassName},学号是{students[i].StuNum}"); 39 } 40 } 41 } 42 }
标签:int pac col names text system read span reading
原文地址:https://www.cnblogs.com/sauhom/p/11634817.html