using System.Collections.Generic;
public static Dictionary<string, int> AverageAgeForEachCompany(List<Employee> employees)
Average = (int)Math.Round(grp.Average(e => e.Age))
ToDictionary(item => item.CompanyName.ToString(), item=> item.Average);
public static Dictionary<string, int> CountOfEmployeesForEachCompany(List<Employee> employees)
ToDictionary(item => item.CompanyName.ToString(), item => item.Count);
public static Dictionary<string, Employee> OldestAgeForEachCompany(List<Employee> employees)
Emp = employees.Where(p => p.Company == grp.Key && p.Age == (int)grp.Max(e => e.Age)).FirstOrDefault()
}).ToDictionary(item => item.CompanyName.ToString(), item => item.Emp);
ToDictionary(item => item.CompanyName.ToString(), item => item.Count);
public static Dictionary<string, Employee> OldestAgeForEachCompany(List<Employee> employees)
public static void Main()
int countOfEmployees = int.Parse(Console.ReadLine());
var employees = new List<Employee>();
for (int i = 0; i < countOfEmployees; i++)
string str = Console.ReadLine();
string[] strArr = str.Split(' ');
employees.Add(new Employee {
Age = int.Parse(strArr[3])
foreach (var emp in AverageAgeForEachCompany(employees))
Console.WriteLine($"The average age for company {emp.Key} is {emp.Value}");
foreach (var emp in CountOfEmployeesForEachCompany(employees))
Console.WriteLine($"The count of employees for company {emp.Key} is {emp.Value}");
foreach (var emp in OldestAgeForEachCompany(employees))
Console.WriteLine($"The oldest employee of company {emp.Key} is {emp.Value.FirstName} {emp.Value.LastName} having age {emp.Value.Age}");
public string FirstName { get; set; }
public string LastName { get; set; }
public int Age { get; set; }
public string Company { get; set; }