.NET naming convention for “ID” (anything identification: Capitalization)

前端 未结 7 954
情歌与酒
情歌与酒 2021-01-31 08:52

I am in the process of unifying these inconsistent naming conventions and this one problem has been a bit driving me crazy lately.

In the code base I am working with has

7条回答
  •  眼角桃花
    2021-01-31 09:04

    Microsoft has updated its guidelines since this question was asked.

    In the MSDN article Capitalization Conventions (.NET Framework 4.5), there is a section named Capitalizing Compound Words and Common Terms. Within the table in this section, the following capitalization guidelines are given for the abbreviation for "identifier" when naming identifiers:

    • When Pascal casing applies, use Id. (Example: System.Attribute.TypeId)
    • When Camel casing applies, use id. (Example: var id = 42;)
    • Never use ID.

提交回复
热议问题