学生类 public class Student { public string name; //姓名 public double score; //成绩 public void showInfo() { //输出信息 Console.WriteLine(name+"\t"+score); } } 初始化数组 static void Main(string[] args) { //定义对象数组 Student[] stus = new Student[3]; //为对象数组元素赋值 stus[0] = new Student(); stus[0].name = "张三"; stus[0].score = 100; stus[1] = new Student(); stus[1].name = "李四"; stus[1].score = 89; stus[2] = new Student(); stus[2].name = "王五"; stus[2].score = 99; Console.WriteLine("前三名学员的信息"); foreach(Student stu in stus) { stu.showInfo(); } Console.ReadLine(); }