static void Main(string[] args) { Console.WriteLine("My first C# Program {0}", Assembly.GetExecutingAssembly().GetName().Version); //Console.WriteLine("Press any key to quit"); //Console.ReadKey(); /// you cant change the type of the variable var later on. var person = new Person("James", "Mason"); person.Firstname = "Mason"; Console.WriteLine("Person: {0} {1}", person.Firstname, person.Surname); var personRegister = new PersonRegister(); personRegister.PersonEventHandler += WriteNewPersonToConsole; Console.WriteLine($"Person: {personRegister[personRegister.Count -1].Firstname} {personRegister[personRegister.Count-1].Surname}"); Console.WriteLine(personRegister.ReadPersonsFromFile("Persons.txt")); personRegister.Sort(SortBySurename); Comparison <Person> comp = NoCompare; personRegister.Sort(comp); for (int i = 0; i < personRegister.Count; i++) { Console.WriteLine($"{personRegister[i].Firstname} {personRegister[i].Surname}"); } }
static void Main(string[] args) { var personRegister = new PersonRegister(); personRegister.PersonAddedHandlerEvent += ConsoleHandler; personRegister.PersonAddedHandlerEvent += PrintHandler; personRegister.ReadPersonsFromFile("Resources/Persons.txt"); personRegister.Sort(CompareBySurname); personRegister.Sort(CompareByFirstname); personRegister.PrintPersons(); Console.WriteLine("First Match:"); Person p = personRegister.FindPerson(ContainsA); Console.WriteLine($"{p.Firstname} {p.Surname}"); Console.ReadKey(); }