Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- //Опишите класс который хранит пользователей системы.Через объект этого класса мы можем:
- //1)Получить пользователя по имени
- //2)Получить пользователя по Id
- //3)Получить всех пользователей
- //4)Получить пользователей у которых зарплата больше N
- //5)Получить пользователей у которых зарплата меньше N
- //6)Получить пользователей у которых запралта от N1 до N2
- namespace Именование
- {
- class Program
- {
- static void Main(string[] args)
- {
- User user = new User();
- user.GetAll();
- }
- }
- public class User
- {
- public string Name { get; set; }
- public string SurName { get; set; }
- public int Id { get; set; }
- public int Salary { get; set; }
- public User[] users =
- {
- new User {Name= "Том", SurName = "Боткин", Id=1, Salary = 100 },
- new User {Name= "Дима", SurName = "Ширяев", Id=2, Salary = 200 },
- new User {Name= "Саша", SurName = "Верещагин",Id=3, Salary = 300 },
- new User {Name= "Костя",SurName = "Шилдт", Id=4, Salary = 400 },
- new User {Name= "Женя", SurName = "Гербер", Id=5, Salary = 500 },
- };
- public void GetAll()
- {
- Console.WriteLine("Введите значение, и вы получите пользователей у которых зп выше его");
- int Chislo = Convert.ToInt32(Console.ReadLine());
- var selectedUsers = from user in users
- where user.Salary > Chislo
- select user;
- foreach (User user in selectedUsers)
- Console.WriteLine("{0} - {1}", user.Name, user.Salary);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement