peshopbs2

Untitled

Feb 27th, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. class Person
  2. {
  3. public string Name { get; private set; }
  4. public int Age { get; private set; }
  5. public string Phone { get; private set; }
  6.  
  7. public Person(string name, int age, string phone)
  8. {
  9. Name = name;
  10. Age = age;
  11. Phone = phone;
  12. }
  13.  
  14. public void PrintContactInfo()
  15. {
  16. Console.WriteLine($"{Name} ({Age}) - {Phone}");
  17. }
  18.  
  19. public void UpdatePhone(string phone)
  20. {
  21. Phone = phone;
  22. }
  23.  
  24. public override string ToString()
  25. {
  26. return String.Format($"{Name} ({Age}) - {Phone}");
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment