This project has moved. For the latest updates, please go here.
The following rules outline the naming guidelines for properties:
  • Use a noun or noun phrase to name properties.
  • Use Pascal case.
  • Do not use Hungarian notation.
  • Consider creating a property with the same name as its underlying type. For example, if you declare a property named Color, the type of the property should likewise be Color. See the example later in this topic.
  • Do not create private fields for the properties if there is nothing to do except return or set the value.

The following code example illustrates correct property naming.
public class SampleClass {
   public Color BackColor  { get; set; }
}

This language is not supported or no code example is available.

The following code example illustrates providing a property with the same name as a type.
public enum Color {
   // Insert code for Enum here.
}
public class Control {
   public Color Color { get; set; }
}


This language is not supported or no code example is available.

The following code example is incorrect because the property Color is of type Integer.
public enum Color {
  // Insert code for Enum here.
}
public class Control {
   public int Color { get;set;}
}

This language is not supported or no code example is available.

In the incorrect example, it is not possible to refer to the members of the Color enumeration. Color.Xxx will be interpreted as accessing a member that first gets the value of the Color property (type int in C#) and then accesses a member of that value (which would have to be an instance member of System.Int32).

Last edited Jul 15, 2010 at 3:41 PM by camalot, version 2