Mechanics, in this case, refers to the process of selecting a name for a given metadata token in the language such as class, interface, field, parameter, and so on.
Microsoft, in its “Naming Guidelines” topic (under the “.NET Framework Design Guidelines” in the .NET SDK Documentation), contains a list of “Do’s” and “Don’ts” regarding naming guidelines. Rather than reprint that list here in either parroted or paraphrased form, we just make the following general suggestions:
Names should be descriptive and concise. More importantly, they should be meaningful to the principal consumers of the name — use syntax, phraseology, and terms that are familiar to the developers who will use the code you are writing.
As suggested, since classes and interfaces and value types are often marked “public,” use Pascal-case for their names.
Interfaces should always be prefixed with
in COM tradition. Following the Pascal-casing rules, make sure the next letter
of the interface is also capitalized, as in
an interface that provides comparable behavior). Frequently, interfaces
are also descriptive names (
and so on), rather than nouns.
Other than the
I for interfaces, do not use any sort
of prefixes on names. This is what namespaces are for.
Attributes should always end in the
The C# compiler can use shorthand naming rules (allowing you to leave off
Attribute portion of the name when using the attribute) if you follow ...