예제 #1
0
        static void Main(string[] args)
        {
            //KeyValuePair<string, string> arr = new KeyValuePair<string, string>();

            List <User> usersList = new List <User>();

            //for (int i = 0; i < 5; i++)
            //{
            //    usersList.Add(new User()
            //    {
            //        Mail = Console.ReadLine(),
            //        Name = Console.ReadLine()
            //    });
            //}

            usersList = UsersInitializator.InitializeUsersList();

            var usersOlderThanThirty = usersList.Where(x => x.Mail.Contains("second")).ToList();

            var averageYears = usersList.Average(u => u.Age);

            Console.WriteLine("Average years: " + averageYears);

            foreach (var item in usersOlderThanThirty)
            {
                Console.WriteLine(item);
            }

            var maxYears   = usersList.Max(u => u.Age);
            var oldestUser = usersList.First(u => u.Age == maxYears);

            Console.WriteLine("Oldest user is:");
            Console.WriteLine(oldestUser);
        }
예제 #2
0
        static void Main(string[] args)
        {
            using (StreamWriter writer = new StreamWriter(_filePath))
            {
                var usersList = UsersInitializator.InitializeUsersList();

                foreach (var item in usersList)
                {
                    writer.WriteLine(item.WriteUserToFileInSpecificFormat());
                }
            }

            var readUsersList = ReadUsersFromFileAndCreateList();

            foreach (var item in readUsersList)
            {
                Console.WriteLine(item);
            }
        }