02对象数组

来源:互联网 发布:解放战争国民党知乎 编辑:程序博客网 时间:2024/05/01 08:23
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApplication1{    class Class1    {        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 = 66;            stus[2] = new Student();            stus[2].name = "么么哒";            stus[2].score = 88;            Console.WriteLine("前三名学员的信息为:");            foreach (Student stu in stus)            {                stu.showInfo();            }            Console.ReadLine();        }    }}

0 0
原创粉丝点击