C.5. Naming C# properties

If you choose to use the same name for a public or protected property which 'represents' a private field in a C# class, they should be differentiated by capitalization. The public/protected property name should use Pascal casing, while the private field should use camel casing. Here is an example:

 1:  private string name; // private field name
 2:
 3:  public string Name{ // property Name
 4:    get{
 5:      return name;
 6:    }
 7:    set {
 8:      name = value;
 9:    }
10:  }

Get From Java to C#: A Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.