I recently started working with Unity3D and primarily scripting with C#. As I normally program in Java, the differences aren't too great but I still referred to a crash course just to make sure I am on the right track.

However, my biggest curiosity with C# is that it capitalises the first letter of its method names (eg. Java: getPrime() C#: GetPrime() aka: Pascal Case?). Is there a good reason for this? I understand from the crash course page that I read that apparently it's convention for .Net and I have no way of ever changing it, but I am curious to hear why it was done like this as opposed to the normal (relative?) camel case that, say, Java uses.

Note: I understand that languages have their own coding conventions (Python methods are all lower case which also applies in this question) but I've never really understood why it isn't formalised into a standard.

  • 18
    I really don't think you can look at camelCase and PascalCase and underscore_case and say that one of them is normal (even relatively normal) and the others not. As @dasblinkenlight said, it's an arbitrary choice. The only thing making you think that C#'s convention unusual is that you "normally program in Java", and are thus accustomed to the arbitrary choice made for Java. Commented Aug 2, 2012 at 5:00
  • Use JavaScript instead.. for Unity3D :)
    – Lipis
    Commented Aug 7, 2012 at 0:54
  • @Lipis Why for - other than personal taste? ;-)
    – ahodder
    Commented Aug 7, 2012 at 14:58
  • @AedonEtLIRA totally personal.. never mind :) Enjoy Unity no matter what language.. you'll end up using..
    – Lipis
    Commented Aug 7, 2012 at 22:13
  • @Lipis So far it's great. Tons of bells and whistles and I haven't yet dropped money on it yet. But I do prefer the structured style of C# (c/c++) and java.
    – ahodder
    Commented Aug 7, 2012 at 22:29

3 Answers 3


Naming conventions represent arbitrary choices of their publisher. There is nothing in the language itself to prohibit you from naming your methods the way you do in Java: as long as the first character is a letter/underscore, and all other characters are letters, digits, or underscores, C# is not going to complain. However, the class libraries that come with .NET follow a convention that Microsoft has adopted internally. Microsoft also published these guidelines, so that others may choose to adopt them for their own class libraries too. Although it is your choice to follow or to ignore Microsoft's guidelines, familiarization with your code by others may go faster if you follow the same naming guidelines.

  • 1
    However there is usually some rationale behind a convention, and when I read "Is there a good reason for this?" I understand it as a question about WHY not WHAT. Commented Oct 8, 2013 at 9:42
  • Pascal for public/internal/static members and all methods. Camel for private. It helps distinguish the scope of a token while you scan it. The this keyword does the same. The style choices are practical, even if they may appear alien
    – Gusdor
    Commented Dec 26, 2016 at 11:16

Perhaps due to Pascal / Delphi influence. The creator of C# and Delphi was the same person after all (Anders Hejlsberg).

Delphi coding conventions by and large happen to be the same as C#'s in this aspect; see http://www.econos.de/delphi/cs.html#ObjectPascal_Procedures or http://wiki.delphi-jedi.org/index.php?title=Style_Guide#Method_Naming - coincidence?

  • 4
    A +1 for this because it gives what may be the actual reason why this particular arbitrary choice was made for C#. Commented Jul 3, 2013 at 20:11

In addition to the other answers made, having camel case for methods means that they can conflict with names for private members, parameters and method variables that use camel case for their naming. In Java (and C# 1.0) this isn't terribly common since delegate use is awkward and rare. In modern C# it's not exactly common, but it's also not unheard-of.

  • 1
    The underscore should not be used in C# private fields (see blogs.msdn.com/b/brada/archive/2005/01/26/361363.aspx, e.g), but it's controversial and often found.
    – Jens
    Commented Aug 2, 2012 at 7:05
  • 1
    relying on casing to distinguish between language constructs is a really bad idea, regardless of whether the language allows you to do it or not.
    – gbjbaanb
    Commented Aug 2, 2012 at 10:11
  • 4
    @Telastyn that statement is pretty shocking. Most of the .NET class library uses that convention.
    – MattDavey
    Commented Aug 2, 2012 at 14:31
  • 2
    @MarjanVenema : not sure what you are talking about but C# is quite case sensitive and you can certainly have collisions between similarly cased members. This gets fun and exciting when you have actual case INsensitive languages like VB.NET you are working with on a library level. Commented Jul 3, 2013 at 18:07
  • 2
    @Telastyn member variables are not, however, distinguished from variables that are scoped to methods. I for one highly prefer member variables prefixed with underscores and I see examples of it all through code from Microsoft, so I'm not the only one. Commented Jun 23, 2016 at 2:20

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