.net - 属性 'ID' : ID or Id? 的正确命名约定是什么

标签 .net naming-conventions fxcop

非常简单的问题:当我有一个持久对象时,它通常有一个名为 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/

相关文章:

c# - 秒表的数据绑定(bind)问题已过去

c# - 在 .NET 中,Dictionary<string,TValue> 是否存在键冲突

Java 接口(interface)命名约定

ios - Objective C 中方法名称的命名约定

c# - CA1500 与 SA1309 - 哪一个获胜?

c# - CS8019 临时文件 MSBuild 服务器上的 Assemblyinfo 错误

c# - 在接口(interface)中传递方法

.net - 正则表达式匹配所有

opengl-es - "GL_RENDERBUFFER_OES"中的 OES 意味着什么?

visual-studio-2012 - FxCop 自定义规则在 VS2012 中没有名称(但 "official"规则有名称)