Advertisement
Prohause

Person Class

Nov 5th, 2018
865
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. namespace DefiningClasses
  2. {
  3. public class Person
  4. {
  5. private string name;
  6. private int age;
  7.  
  8. public string Name
  9. {
  10. get
  11. {
  12. return name;
  13. }
  14. set
  15. {
  16. name = value;
  17. }
  18. }
  19.  
  20. public int Age
  21. {
  22. get
  23. {
  24. return age;
  25. }
  26. set
  27. {
  28. age = value;
  29. }
  30. }
  31.  
  32. public Person(string name, int age)
  33. {
  34. Name = name;
  35. Age = age;
  36. }
  37.  
  38. public Person(int age) : this("No name", age)
  39. {
  40. }
  41.  
  42. public Person() : this("No name", 1)
  43. {
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement