Total .NET Analyzer Rule Documentation |
|
Avoid having multiple objects with names that differ only by case.
Remarks
Case-sensitive languages, such as C#, allow you to use case sensitivity to identify members. For example, the following code example uses two variables with names that differ only by case:
class MyClass
{
protected int length;
public int Length
{
get
{
return length;
}
}
}
Although this does not cause any functionality or performance problems, it is generally not a good idea. Using case sensitivity to identify members can cause confusion and lead to code that is difficult to read and maintain. Additionally, the code is not portable to other .NET languages that are not case sensitive.
Resolution
To avoid confusion and guarantee cross-language interoperation, you should never create multiple objects (e.g. functions, parameters, namespaces, types, properties, methods) with names that differ only by case.
For example, you could modify the code example above change to use more descriptive names, such as:
class MyClass
{
protected int internalLength;
public int Length
{
get
{
return internalLength;
}
}
}
See Also
Case Sensitivity