• Source
    1. public class Person
    2. {
    3. // Field
    4. public string name;
    5.  
    6. // Constructor that takes no arguments.
    7. public Person()
    8. {
    9. name = "unknown";
    10. }
    11.  
    12. // Constructor that takes one argument.
    13. public Person(string nm)
    14. {
    15. name = nm;
    16. }
    17.  
    18. // Access Methods
    19. public string GetName(){
    20. return name;
    21. }
    22.  
    23. public void SetName(string newName)
    24. {
    25. name = newName;
    26. }
    27.  
    28. }