Code style for private methods in C# [closed]

All method names in C# start with an upper-case letter by convention. All property names do so too. Only private fields, local variables and parameters to methods start with a lower-case letter (AFAIR).

It’s a convention so asking for a »why« is a little misplaced. It’s probably akin to asking »Why does the Java coding convention prefer lower-case letters for everything except classes?«—answers to such questions are usually »Because someone, somewhere, once decided that it’d be a good idea to do so«. The rest then merely is history—or convention and you either follow it or you don’t (in which case you make the lives of people reading your code harder).

ETA: As said in a comment already, (imho) the answer to the question »why?« usually leads to what the language designers (or the people coming up with the convention) considered to be important aspects to be covered by the convention. In Java it’s clearly a case of visually distinguishing classes (PascalCase), variables/fields (camelCase) and properties (get~()/set~()). For .NET there obviously was a need of immediately telling classes and interfaces apart (something I consider pretty nice to have too) and visually distinguishing property (PascalCase) and field (camelCase) access.

Usually in such scenarios all things not initially considered important for the convention fall short in obviousness.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)