public static void Main() { List<Student> students = new List<Student>(); students.Add(new Student("Chiflik", "Isterov", "5869898")); students.Add(new Student("Minka", "Petrova", "8789755")); students.Add(new Student("Sashka", "Ribarova", "1251125")); students.Add(new Student("Boiko", "Filipov", "54687563")); students.Add(new Student("Cvetan", "Gospodinov", "1234456")); students.Add(new Student("Dimitar", "Ganchev", "6668755")); students.Add(new Student("Alexander", "Dimitrov", "2222222")); students.Add(new Student("Dobrinka", "Ivankova", "552552")); students.Add(new Student("Geograf", "Vasilev", "52522")); students.Add(new Student("Penka", "Lopatkova", "3332212")); foreach (var student in students.OrderBy(student => student.FacultyNumber)) { Console.WriteLine("{0}{1} - Faculty number: {2}", student.FirstName, student.SecondName, student.FacultyNumber); } Console.WriteLine(); List<Worker> workers = new List<Worker>(); workers.Add(new Worker("Chiflik", "Isterov", 500, 8)); workers.Add(new Worker("Minka", "Petrova", 200, 4)); workers.Add(new Worker("Marmar", "Vylov", 500, 6)); workers.Add(new Worker("Petar", "Yanov", 550, 8)); workers.Add(new Worker("Yonko", "Narov", 650, 7)); workers.Add(new Worker("Milica", "Dimitrova", 250, 2)); workers.Add(new Worker("Ognqn", "Serafimov", 850, 8)); workers.Add(new Worker("Evelina", "Dimitrova", 1050, 10)); workers.Add(new Worker("Kristina", "Kirilova", 1250, 16)); workers.Add(new Worker("Korleone", "With Al Kapone", 300, 8)); foreach (var worker in workers.OrderByDescending(worker => worker.MoneyPerHour())) { Console.WriteLine("{0} {1} - Money per hour: {2:f2}", worker.FirstName, worker.SecondName, worker.MoneyPerHour()); } Console.WriteLine(); List<Human> studentsAndWorkers = new List<Human>(); studentsAndWorkers.AddRange(students); studentsAndWorkers.AddRange(workers); foreach (var studentOrWorker in studentsAndWorkers.OrderBy(h => h.FirstName).ThenBy(h => h.SecondName)) { Console.WriteLine("{0} {1}", studentOrWorker.FirstName, studentOrWorker.SecondName); } }
static void Main(string[] args) { List<Student> students = new List<Student>() { new Student("Angel","Angelov","12343"), new Student("Bojidar","Bratoev","432d213"), new Student("Cikoriq","Ciklamena","hd732j"), new Student("Dobra","Dudeva","9189819"), new Student("Elen","Elenov","72j21"), new Student("Fred","Flinstone","3fjjf2"), new Student("Gergana","Grudeva","8932929"), new Student("Haralambii","Hristov","r8w0q"), new Student("Iliq","Iliev","erdew"), new Student("Jecho","Jechev","73h371") }; List<Worker> workers = new List<Worker>() { new Worker("Anton","Antonov",100,2), new Worker("Borko","Biserov",300,8), new Worker("Cveta","Cimilova",200,4), new Worker("Duda","DObreva",600,4), new Worker("Emiliq","Encheva",120, 2), new Worker("Fani","Filipova",130,8), new Worker("Grigorii","Georgoev",200,8), new Worker("Hristo","Hristov",246,8), new Worker("Ivan","Ivanov",250,8), new Worker("Jelqzko","Jelev",200,8) }; Console.WriteLine("###Students###"); students.OrderBy(st => st.StudentNumber).ToList().ForEach(st => Console.WriteLine("{0} -stud number-> {1}", st.FistName, st.StudentNumber)); Console.WriteLine("###Workers###"); workers.OrderByDescending(wr => wr.MoneyPerHour()).ToList().ForEach(wr => Console.WriteLine("{0} -money per hour->{1}", wr.FistName, wr.MoneyPerHour())); List<Human> humans = new List<Human>(); humans.AddRange(workers); humans.AddRange(students); Console.WriteLine("###Humans###"); humans .OrderBy(h => h.FistName) .ThenBy(h => h.LastName) .ToList() .ForEach(h => Console.WriteLine("{0} {1}", h.FistName, h.LastName)); }