Пример #1
0
 private void Show(PersonOp <Student> st, int n)
 {
     for (int i = 0; i < n; i++)
     {
         Console.WriteLine(st.persons[i].name + " " + st.persons[i].age);
     }
 }
Пример #2
0
        public GenericsOp()
        {
            SampleOperation <int> variable = new SampleOperation <int>();
            int a = variable.Atribute(2);

            Console.WriteLine("Generic. Int Atribute: " + a);

            SampleOperation <float> variable2 = new SampleOperation <float>();
            float f = variable2.Atribute(2.22f);

            Console.WriteLine("Generic. Float Atribute: " + f);

            students = new PersonOp <Student>();
            Student[] sts = new Student[] { new Student {
                                                name = "Ion", age = 12
                                            },
                                            new Student {
                                                name = "irina", age = 13
                                            } };
            students.ReplaceAll(sts, 2);

            Console.WriteLine("Initial list:");
            Show(students, 2);

            students.persons[1].name = "Aleona";
            students.persons[1].age  = 11;

            Console.WriteLine("\n Modificated list:");
            Show(students, 2);
        }