Information Technology Reference
In-Depth Information
There are several conventions for naming properties and their associated fields. One con-
vention is to use the same string for both names, but use camel casing (in which the first letter
is lowercase) for the field and Pascal casing for the property. This violates the general rule that
it is bad practice to have different identifiers that differ only in casing, but it has the advantage
of tying the two identifiers together in a meaningful way.
Another convention is to use Pascal casing for the property, and for the field, use an under-
score in front of the same identifier.
The following code shows both conventions:
private int firstField; // Camel casing
public int FirstField // Pascal casing
{
get { return firstField; } set { firstField = value; }
}
private int _SecondField; // Underscore
public int SecondField
{
get { return _SecondField; } set { _SecondField = value; }
}
Search WWH ::




Custom Search