I'm just starting to learn C#. Coming from a background in Java, C++ and Objective-C, I find C#'s Pascal-casing its method-names rather unique, and a tad difficult to get used to at first. What is the reasoning and philosophy behind this?

I'm guessing it is because of C# properties. Unlike in Objective-C, where method names can be exactly the same as an instance variables, this is not the case with C#. I would guess one of the goals with properties (as it is with most of the languages that support it) is to make properties truly indistinguishable from variables and methods. So, one can have an "int x" in C#, and the corresponding property becomes X. To ensure that properties and methods are indistinguishable, all method names I'm guessing are also therefore expected to start with an uppercase letter. (This is just my hypothesis based on what I know of C# so far—I'm still learning). I'm very curious to know how this curious guideline came into being (given that it's not something one sees in most other languages where method names are expected to start with a lowercase letter)

(EDIT: By Pascal-casing, I mean PascalCase (which is basically camelCase but starting with a capital letter). Method names typically start with a lowercase letter in most languages)

  • If you saw that all the members of a certain family had all their walls in all their houses painted with a strange insignia, would you be curious why they did it such a strange thing?
    – Debajit
    Mar 1 '11 at 19:12
  • 1
    Why do you think it is called Pascal case? Mar 1 '11 at 19:14
  • 1
    @Martinho Fernandes it is standard name for this style, check Google
    – Andrey
    Mar 1 '11 at 19:16
  • 1
    @Nocturne - Yes. I would be curious :) Mar 1 '11 at 19:17
  • 1
    The "method names start with a lowercase letter in most languages" is false in my experience. Conventions starting with an uppercase letter - with or without underscore word-separating - are quite common, though not necessarily in official language guidelines. Most language standards don't have any single official style guides. Quite a few languages (mainly older) ignore case anyway, and often have an everything-lowercase convention because don't-press-shift is the laziest rule that means you don't get differently-mixed-case spellings treated as the same confusion.
    – Steve314
    May 13 '11 at 21:46

It is matter of taste. Someone once decided to use Pascal style for names and it became a standard.

I have a wild guess that it was Anders Hejlsberg, who was architect of Delphi, successor of Pascal. Case style is same there as in C#.

  • this was going to be my answer. :P
    – DevSolo
    Mar 1 '11 at 19:23
  • @DevSolo sorry, I started typing answer when question was at Stackoverflow :)
    – Andrey
    Mar 1 '11 at 19:26
  • I think that the roots go even deeper into ancient history - see my answer below :)
    – davka
    Mar 1 '11 at 22:14

If you are asking about reasons, here is one straight from the horse's mouth:

History around Pascal Casing and Camel Casing article by Brad Abrams at MSDN blogs

In the initial design of the Framework we had hundreds of hours of debate about naming style. To facilitate these debates we coined a number of terms. With Anders Heilsberg (the original designer of Turbo Pascal) a key member of the design team, it is no wonder that we chose the term Pascal Casing for the casing style popularized by the Pascal programming language...

Pascal Casing convention capitalizes the first character of each word (including acronyms over two letters in length)...

And here are the design guidelines: Design Guidelines for Class Library Developers

These guidelines are intended to help class library designers understand the trade-offs between different solutions. There might be situations where good library design requires that you violate these design guidelines. Such cases should be rare, and it is important that you provide a solid justification for your decision. The section provides naming and usage guidelines for types in the .NET Framework as well as guidelines for implementing common design patterns...

  • 2
    TurboPascal is the baby of Philip Kahn (aka Borland) which is very convenient for Microsoft to forget. Politics....
    – davka
    Mar 1 '11 at 22:19
  • 1
    The comments on the first link are great, lol.
    – jmq
    Mar 1 '11 at 22:20

Don't know about philosphy, but Pascal casing seems to be common on Microsoft platforms since at least Win32 API days.

  • 11
    and I still hate it, lol.
    – jmq
    Mar 1 '11 at 22:19

I don't think there was a specific philosophy behind it. There needed to be guidelines, and there were many points that may have affected it:

  • They wanted to get rid of any prefix notations (read hungarian here)
  • They wanted that local/private members and public members be distinguished by just reading their names.
  • They did not want C# code look like Java code (which heavily uses camel case)
  • Note that this naming guideline is for the .NET framework and not C# in particular. In VB.NET, a case-insensitive language, the convention remains the same, but you cannot use it distinguish private and public members by case. Mar 1 '11 at 19:21
  • @Martinho: agreed. but I still feel is was one of the reasons.
    – decyclone
    Mar 1 '11 at 19:22
  • 10
    +1: "They did not want C# code look like Java code (which heavily uses camel case)": I strongly suspect you are right here!
    – Giorgio
    Apr 21 '12 at 16:41
  • What's ironic is that despite some people's hatred of Hungarian notation, Java and C# would probably have both been much better languages in practice if they had adopted Apps Hungarian (or other naming convention) to distinguish reference-type fields that "own" a mutable object identified thereby, those which identify a mutable-type instance that must never be mutated, etc. Even if the Runtime doesn't care about such distinctions, it's impossible to write code which is efficient and correct without knowing which variables are of what kind.
    – supercat
    Nov 4 '14 at 22:22
  • I dissagree with the second point, whenever methods are called they are followed by parentheses so why would any one mistake them for members?
    – Darthcow
    Jan 5 at 13:08

I don't know that there is a "philosophy" behind the casing other than it's nice and compact and can easily appear as multiple words without using underscores.

There's been many variations of casing over the past few decades. They've ranged from very terse (see C and the standard C library) to verbose with underscores separating each word. While the .NET library convention of naming is still pretty verbose, I think it strikes some middle ground as far as casing.

  • 5
    do-not-forget-lisp-style-naming! Mar 1 '11 at 19:16
  • @Martinho Fernandes actually in context of c-like languages it is not valid.
    – Andrey
    Mar 1 '11 at 19:20
  • Yeah, Lisp takes whitespace into account. (- var1 var2)
    – Michael K
    Mar 1 '11 at 19:31
  • @Martinho Fernandes: Of course, that requires the use of whitespace to separate tokens. It's also COBOL-STYLE-NAMING, which makes it common to the languages I most admire and least admire. Mar 1 '11 at 19:55

Taking a wild (but not unreasonable, IMHO) guess - C# design was supervised by Niklaus Wirth, the original inventor of Pascal. See the connection?... :)

Curious #1: I positively remember the announcement of .NET and C# (yes, I am prehistoric...) and how Microsoft bragged by having Wirth's name on C#. Yet, the Wikipedia pages on neither (C# and Wirth) mention this.

Curious #2: Although it is called PascalCase, it was popularized by the TurboPascal compiler (which eventually became Borland), not the language itself.

  • 4
    and TurboPascal was conveniently designed and built by Anders Hejlsberg...
    – SWeko
    Mar 2 '11 at 8:08
  • 3
    Anders Hejlsberg was IIRC the lead designer of Delphi, and worked a lot on Turbo Pascal, but Turbo Pascal wasn't originally his baby (it was Philip Kahns). Niklaus Wirth invented the original Pascal and took it through standardisation, then saw the standard largely ignored. Also, Wirth has been retired for just about the whole of the life of C#, and before then designed several successor-to-Pascal languages (most recently Oberon 2) so I doubt he had any direct involvement at all. Microsoft bragged loudly about having Hejlsberg on board. Turbo Pascal was a Borland product from the start.
    – Steve314
    May 13 '11 at 21:35
  • I don't mind downgrading - I have enough points on StackOverflow, but I am curious about the reason
    – davka
    Apr 13 '14 at 13:36

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