Pascal casing or Camel Casing for C# code?

后端 未结 14 1031
终归单人心
终归单人心 2020-12-05 17:17

I\'ve been arguing with my coworkers about Pascal casing (upper camel case) vs. lower CamelCasing. They are used to lower camel casing for everything from table names in SQL

14条回答
  •  春和景丽
    2020-12-05 18:07

    Actually, there's no "standard" convention on this. There's a Microsoft edited guideline somewhere, and as with with any other naming convention guideline, surely there's another one refuting it, but here's what I've come to understand as "standard C# casing convention".

    1. PerWordCaps in type names (classes, enums), constants and properties.
    2. camelCase for really long local variables and protected/private variables
    3. No ALL_CAPS ever (well, only in compiler defines, but not in your code)
    4. It seems some of the system classes use underscored names (_name) for private variables, but I guess that comes from the original writer's background as most of them came straight from C++. Also, notice that VB.NET isn't case sensitive, so you wouldn't be able to access the protected variables if you extended the class.

    Actually, FxCop will enforce a few of those rules, but (AFAIK) it ignores whatever spelling you use for local variables.

提交回复
热议问题