.net – 属性“ID”的正确命名约定是什么?ID或Id?




public int ID { get; set; }


public int Id { get; set; }


PS。这是为.NET btw。 FXCop一致将是一个奖金。


.NET Framework Naming Guidelines说:

An acronym is a word that is formed from the letters of words in a term or phrase. For example, HTML is an acronym for Hypertext Markup Language. You should include acronyms in identifiers only when they are widely known and well understood. Acronyms differ from abbreviations in that an abbreviation shortens a single word. For example, ID is an abbreviation for identifier. In general, library names should not use abbreviations.

The two abbreviations that can be used in identifiers are ID and OK. In Pascal-cased identifiers they should appear as Id, and Ok. If used as the first word in a camel-cased identifier, they should appear as id and ok, respectively.

转载注明原文:.net – 属性“ID”的正确命名约定是什么?ID或Id? - 代码日志