private void SortVehicles() { //show unsorted collection Console.WriteLine("Unsorted collection:"); OutputService.PrintVehicleTable(vehicles); //sorting vehicles vehicles = vehicles.OrderBy(item => item); //show sorted collection to console Console.WriteLine("Sorted collection:"); OutputService.PrintVehicleTable(vehicles); }
public void Run() { OutputService.PrintVehicleTable(vehicles); //select same vehicles var sameElements = vehicles.GroupBy(item => item) .Where(g => g.Count() > 1) .Select(y => new { Value = y.Key, Count = y.Count() }); Console.WriteLine("Same Elements:"); foreach (var element in sameElements) { Console.WriteLine($"vehicle: {element.Value.ModelName}, count: {element.Count}"); } }
public void PrintVehicles() { OutputService.PrintVehicleTable(vehicles); }