Advertisement
Ne-Biolog

Untitled

Apr 10th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. public class Person
  2. {
  3. protected int[] a = new int[10];
  4. public int this [int index]
  5. {
  6. get { return a[index]; }
  7. set { a[index] = value; }
  8. }
  9.  
  10. protected int age;
  11. protected string name, surname;
  12. protected static int ID = 0;
  13.  
  14. public int Age
  15. {
  16. get { return age; }
  17. set {
  18. // if (value < 0) throw new ArgumentOutOfRangeException();
  19. if (value < 0)
  20. value = 0;
  21. age = value;
  22.  
  23. }
  24. }
  25.  
  26. public Person(int age, string name, string surname)
  27. {
  28. ID++;
  29. this.Age = age;
  30. this.name = name;
  31. this.surname = surname;
  32. }
  33.  
  34. public void getInfromation()
  35. {
  36. Console.WriteLine("Age = " + age);
  37. Console.WriteLine("Name = " + name);
  38. Console.WriteLine("Surname = " + surname);
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement