コード例 #1
0
        static void Main(string[] args)
        {
            BAStudent y = new BAStudent(true);

            y.Grade = 100;
            MAStudent z = new MAStudent(false);

            Console.WriteLine(y);

            List <Student> StudentsList = new List <Student>();

            StudentsList.Add(y);
            StudentsList.Add(z);
            int i = 0;

            if (StudentsList[i] is BAStudent)
            {
                ((BAStudent)StudentsList[i]).Milga = true; // casting
                Console.WriteLine((StudentsList.First() as BAStudent).Milga);
            }
            foreach (Student s in StudentsList)
            {
                if (s is BAStudent)
                {
                    Console.WriteLine((s as BAStudent).Milga);
                }
            }
            StudentsList.Sort();

            string str = Console.ReadLine();

            int[] arr = TestStringSplit.ToIntArray(str);
        }
コード例 #2
0
        private void pbStartWeek3_Click(object sender, RoutedEventArgs e)
        {
            BAStudent bA = new BAStudent(true);
            MAStudent mA = new MAStudent(false);

            bool b = rbOne.IsChecked.Value;

            List <Student> students = new List <Student>();

            students.Add(bA);
            students.Add(mA);
            students.Add(new BAStudent("Avraham", false));

            Student st = students[2];

            students.Sort();
            Student max = students.Max();


            tb_StudentDetails.Text = "";
            foreach (Student s in students)
            {
                if (s is BAStudent)
                {
                    bool m = (s as BAStudent).Milga;
                    tb_StudentDetails.Text += s.ToString() + "\n";
                }
            }
            int a = Convert.ToInt32(DateTime.Now);
        }