I want to know the rules of naming (AlwaysCapitalize, _underscore, firstSmallLetter, etc...) for each of Namespaces, Classes, Interfaces, Exceptions, Data Members, Methods, Variables, etc....

also I would like to know:

  • Are they standards?
  • Do they differ According to the access modifiers? (public, private.....)
  • What about compiler and library reserved formats?
  • Also are they Language, IDE, or Framework relative?

I only know that these rules exist, but don't actually know any.

Any help would be appreciated.

EDIT: OK, if the question is really wide, then I have to narrow my question:

What are the naming rules of Classes, Interfaces, Data Members, and Methods in C# (and Java if possible).

Also, inspired by Renesis's comment, I've created a wiki to write Coding Conventions, here's the link:


closed as not a real question by Nicole, yannis, Walter, ChrisF Dec 16 '11 at 11:07

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    Your question is overly broad - you're asking for an encyclopedia about naming standards. Any way you can narrow it down? – Nicole Dec 2 '11 at 0:43
  • @Renesis: You're right, I myself suspected that but I wanted to be greedy :D, I've just narrowed my question. – Tamer Shlash Dec 2 '11 at 1:31
  • @Mr.TAMER Good for you that you tried to narrow down the question, but it doesn't make much difference, you are still asking for quite a lot. There aren't any standard rules, unfortunately, as BillThor writes in his answer. Every project has it's own conventions, some are very common and shared across projects and some are not. There is no kind of consistency though. The best way to make some sense of popular conventions (not standard, just popular) is look at what's used on established open source projects and dev references like MSDN. – yannis Dec 2 '11 at 1:44
  • @Mr.TAMER Some may argue that the "standard" conventions for a language are those used in the "standard" reference documentation or the specification of the language, if it exists. But that's not always true, several projects may opt to follow slightly or even largely different conventions. – yannis Dec 2 '11 at 1:47
Are they standards?

In general, they are coding conventions not standards. Following the conventions makes reading the code much easier. Companies and projects may adopt particular conventions as their standard.

Do they differ According to the access modifiers? (public, private.....)

This is dependent on the conventions in use.

What about compiler and library reserved formats?

Compilers and libraries commonly use underscores at the beginning or end of identifiers. Programmers should avoid such identifiers unless they fully understand the implications.

Also are they Language, IDE, or Framework relative?

Different languages have different conventions. Some languages have competing conventions. Most frameworks will have a convention, but not all frameworks have the same convention.

IDEs may provide support for coding conventions. Many have add-ins which will allow the use of style validation tools within the IDE>

EDIT: Java has a recommended coding style now available from Oracle. I don't work with C#, so I don't know if there are competing standards to the MSDN C# coding standards. These would be a good starting point for your own standards.

When working with existing code try to follow the same conventions as the current code. Working with code that has been coded with a variety conventions can be very confusing.

You may find it useful to be familiar with a number of conventions. You will likely encounter a number of them as you work with different code bases. When working on new code select a set of code conventions and stick to them.


I'd suggest taking a look at stylecop ( or fxcop and its naming warnings ) and other similar tools.

Stylecop is a static C# code analyzer that enforces the naming conventions you want to find out. So by checking its rules you can see the information you want.

Not the answer you're looking for? Browse other questions tagged or ask your own question.