非常简单的问题:当我有一个持久对象时,它通常有一个名为 ID 的属性(对于抽象类)。
那么..命名约定是ID还是Id?
例如。
public int ID { get; set; }
或
public int Id { get; set; }
干杯:)
PS。顺便说一句,这是针对 .NET 的。 FXCop 一致性将是一个额外的好处。最佳答案
我通常使用标识符。如果我确实想保持简短(例如,作为较长标识符的一部分),我会使用 Id,除非它是参数或私有(private)成员。
.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 or Id? 的正确命名约定是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/264823/