static void Main(string[] args)
        {
            Student s = new Student(1, "Gavin", GENDER.MALE);

            Class sclass = new Class(2, "Tom");
            sclass.AddStudent(2, "Bob", GENDER.MALE);
            sclass.AddStudent(3, "Lucy", GENDER.FEMALE);
            sclass.AddStudent(4, "Sarah", GENDER.FEMALE);
            sclass.AddStudent(5, "Richard", GENDER.MALE);
            sclass.AddStudent(2, "Mia", GENDER.FEMALE);

            sclass[3] = s;
            sclass[4] = s;

            Console.WriteLine(sclass[3].ToString());
            Console.WriteLine(sclass[2].ToString());

            Console.Read();
        }
Example #2
0
 public void addStudent(Student stu)
 {
     this.students.Add(stu);
 }
        private bool IsStudentDataLegal(Student value)
        {
            var query = from Student student in Students
                        where student.ID == value.ID
                        select student; //Decided to use LINQ for searching the array list

            if (query.Count() > 0 || value.Name == null || value.Gender == null)
            {
                return false;
            }
            else
            {
                return true;
            }
        }