private static void Main(string[] args)
        {
            Student[] students = new Student[]
            {
                new Student() { Name = "John", ChineseGrade = 80, EnglishGrade = 77, MathGrade = 30 },
                new Student() { Name = "Bob", ChineseGrade = 30, EnglishGrade = 37, MathGrade = 99 },
                new Student() { Name = "Marry", ChineseGrade = 99, EnglishGrade = 69, MathGrade = 80 }
            };

            do
            {
                Console.WriteLine("你想以哪個分數做排序:1.總分 2.國文 3.英文 4.數學 5.結束");
                Student.Key = Convert.ToInt32(Console.ReadLine());

                if (Student.Key == 5) { Console.WriteLine("結束查詢"); }
                else
                {
                    Console.WriteLine("姓名\t總分\t國文\t英文\t數學");
                    Array.Sort(students);
                    foreach (Student student in students)
                    {
                        Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", student.Name, student.TotalGrade, student.ChineseGrade, student.EnglishGrade, student.MathGrade);
                    }
                }
            } while (Student.Key != 5);
        }
Example #2
0
        private static void Main(string[] args)
        {
            //     int[] grades = new int[10];

            //   int length = 10;
            // int[] grades2 = new int[length];

            //  int length2 = int.Parse(Console.ReadLine());
            //  int[] grades3 = new int[length2];

            //            int[] grades4 = new int[] { 3, 2, 1 };

            //          int[] grades5 = { 4, 5, 6 };

            //        int[] grades6;
            //      grades6 = new int[] { 5, 6, 7, 8 };

            //    int[,] table = new int[,]
            //  {
            //    {1,2,4 },
            //   {3,4,5 }
            //  };

            //   int[][] table2 = new int { { 1, 2 }, { 4, 5 } };
            Student[] students = new Student[3];
            students[0] = new Student() { name = "A" };
            students[1] = new Student() { name = "B" };
            students[2] = new Student() { name = "C" };
            //            Student[] students2 = new Student [3]
            string[] names = { "A", "B", "C" };
            for (int number = 0; number < students.Length; number++)
            {
                students[number] = new Student { name = names[number] };
                students[number].SayHello();
                students[number].Print();
            }
            foreach (Student student in students)
            {
                student.SayHello();
                student.Print();
            }
        }
Example #3
0
 protected override int ApplyStateTaxes(Student objStudent)
 {
     return(5);
 }