static void Main(string[] args) { Activity act1 = new Activity("Tenis", true); Pupil pup1 = new Pupil("Arnaud", 12, 1); pup1.AddActivity(act1); Pupil pupilGrade1 = new Pupil("Corentin", 15, 1); Activity coloriage = new Activity("Coloriage", true); pupilGrade1.AddActivity(coloriage); pupilGrade1.AddEvaluation("Coloriage"); List<Pupil> ListPupil = new List<Pupil>() { new Pupil("Alexandre",12,1), new Pupil("Jacky",14,3), new Pupil("Dan",3,3), }; ///////////////////////////////Ex Covariance List<Pupil> listPupils2 = new List<Pupil>()//Exercice Covariance { new Pupil("Kevin",21,2), new Pupil("Nicolas",5,1), new Pupil("Corentin",7,1), }; List<Pupil> listPersons = new List<Pupil>()//Exercice Covariance { new Pupil("Bertrand",21,3), new Pupil("Serge",19,2), new Pupil("Luc",16,1), }; var listFusion = listPersons.Union(listPupils2); foreach (var pupil2 in listFusion) { System.Console.Write(pupil2); } List<Pupil> listPupilsDuplicated = new List<Pupil>() { new Pupil("Kevin",21,2), new Pupil("George",13,1), new Pupil("Donatello",5,1), new Pupil("Corentin",7,1), new Pupil("Donatello",5,1), new Pupil("Corentin",7,1), }; IEnumerable<Pupil> listPupilsNoDuplicated = listPupilsDuplicated.Distinct<Pupil>(new PersonComparer()); System.Console.Write("\n Nombre des non dupliqués: " + listPupilsNoDuplicated.Count() + "\n\n"); /////////////////////////// //var pupilGradePlus6 = from pupil in ListPupil // where pupil.Grade == 1 && pupil.Age >= 6 // select pupil; var pupilGradePlus6 = ListPupil.Where(pupil => pupil.Grade == 1 && pupil.Age >= 6); if(pupilGradePlus6 != null) foreach(var pupil in pupilGradePlus6) { //System.Console.Write(pupil); } System.Console.Write(pup1); System.Console.Write(pupilGrade1); System.Console.Read(); }
public void AddActivity(Activity act) { LstActivities.Add(act); }