Advertisement
dsavov_02

new

Apr 13th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp15
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Person[] person = new Person[5];
  14. Person person1 = new Person();
  15. Person person2 = new Person("Ivan", "Petrov", 22, 1600);
  16. Person person3 = new Person("Icko", "Georgiev", 32, 1300);
  17. Person person4 = new Person("Nadq", "Misheva", 23, 1700);
  18. Person person5 = new Person("Plamen", "Petkov", 27, 1300);
  19. person[0] = person1;
  20. person[1] = person2;
  21. person[2] = person3;
  22. person[3] = person4;
  23. person[4] = person5;
  24. CheckSalary(1100, person);
  25. }
  26. static void CheckSalary(int salary, Person[] persons)
  27. {
  28. foreach (var i in persons)
  29. {
  30. if (i.salary > 1200)
  31. {
  32. Console.WriteLine(i.firstname);
  33. }
  34. }
  35. }
  36.  
  37. }
  38. class Person {
  39.  
  40. public string firstname;
  41. string lastname;
  42. int age;
  43. public int salary;
  44.  
  45. public Person (string firstname, string lastname, int age, int salary)
  46. {
  47. this.firstname = firstname;
  48. this.lastname = lastname;
  49. this.age = age;
  50. this.salary = salary;
  51. }
  52. public Person()
  53. {
  54. this.firstname = "Peter";
  55. this.lastname = "Petrov";
  56. this.age = 25;
  57. this.salary = 1500;
  58. }
  59. }
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement