Question about MS's naming conventions..

D

David Sandor

I have been looking at the source code for the CLR (rotor code)... I have
some questions about the naming conventions that Microsoft is using as I
have found what appear to be inconsistencies (or I simply have not figured
it out.)

Take the class definition:

[Serializable()] public class SortedList : IDictionary, ICloneable

{

private Object[] keys;

private Object[] values;

private int _size;

private int version;

private IComparer comparer;

private KeyList keyList;

private ValueList valueList;


private const int _defaultCapacity = 16;

I understand that privates are camel-case (lower case first), however why
does _size employ an underscore? Does the underscore implicate a specific
use?

Additionally in other classes (System.IO.File.cs) they use a method defined
as __Error (2 underscores then uppercase camel-cased). Is this because
__Error is a native/system method/function/import?

Thanks for your help,

David Sandor
 
J

Jon Skeet

I understand that privates are camel-case (lower case first), however why
does _size employ an underscore? Does the underscore implicate a specific
use?

I suspect it implies that different developers worked on the code, to
be honest... I don't believe MS actually suggests one way or another.
Personally I name my member variables without an underscore, and have
never made the mistake of confusing a member variable with a local
variable, which is the charge often leveled against this convention.
Then again, that might be to do with keeping methods nice and short,
which is a good thing for many other reasons :)
 
Top