public void DisplayCourseDetails(Course crs) { if (myCourses.ContainsKey(crs.Csci)) Console.WriteLine(crs); }
public void Add(Course crs) { myCourses.Add(crs.Csci, crs); }
public void Remove(Course crs) { if(myCourses.ContainsKey(crs.Csci)) myCourses.Remove(crs.Csci); }
private static void ImplementIEnumerable() { CourseCollection collect = new CourseCollection(); collect.Add(new Course(456, "S/W Testing", 23)); collect.Add(new Course(457, "Component Based Ent S/W dev", 12)); collect.Add(new Course(458, "Open source", 8)); foreach (KeyValuePair<int, Course> item in collect) { Console.WriteLine(item); } Console.WriteLine(); foreach (KeyValuePair<int, Course> item in collect) { Console.WriteLine(item); } Course[] arr = new Course[3] { new Course(459, "S/W Testing", 23), new Course(45, "Component Based Ent S/W dev", 12), new Course(18, "Open source", 8) }; Console.WriteLine(); if (arr[0].CompareTo(arr[1]) == 1) Console.WriteLine(arr[0] + " has a higer course id"); Console.WriteLine(); //Console.WriteLine("Sort by CSCI"); //Array.Sort(arr, new SortCourseByCSCI()); //foreach (Course item in arr) //{ // Console.WriteLine(item); //} Console.WriteLine("Sort by CSCI"); Array.Sort(arr, new SortByCourseName()); foreach (Course item in arr) { Console.WriteLine(item); } }