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

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

很简单的问题:当我有一个持久性对象时,它通常有一个名为ID的属性(对于抽象类)。

那么..是命名约定ID还是Id?

例如。

public int ID { get; set; }

要么

public int Id { get; set; }

欢呼:)

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

我通常用标识符去。如果我真的想保留它(例如,作为更长的标识符的一部分),我使用Id,除非它是参数或私有成员。

.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.

http://stackoverflow.com/questions/264823/whats-the-proper-naming-convention-for-a-property-id-id-or-id

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:.net – 属性“ID”的正确命名约定是什么?ID或Id?