C# 命名约定(标题与名称)

发布于 2024-10-30 08:44:36 字数 58 浏览 3 评论 0原文

我有一系列类,它们根据您在语义上选择的单词来实现标题(或名称)。标题与名称是否有 C# 命名约定标准?

I have a series of classes that implement a Title (or Name) depending upon which word you semantically choose. Is there a C# naming convention standard for Title vs Name?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓝天白云 2024-11-06 08:44:36

两者都很常见。

根据我的观察,Name 更频繁地用于具有内部名称的对象或自然具有 Name 属性的业务对象(例如人)。例如,请考虑 MemberInfo.NameIIdentity.Name。文件通常被认为具有“文件名”,而名称通常至少是对象身份的一部分。

标题更常用于指代用户界面控制对象或自然具有标题的业务对象,例如文章。

就我个人而言,我认为标题是人类可读的东西,而名称更多的是本地范围的标识符,可能是也可能不是人类可读的。 (我并不是说该名称必须是完全唯一的,但在许多情况下,它是 - 无论哪种方式,它往往会在其使用上下文中提供一些标识)。我从概念上认为“标题”更接近于与“标签”的互换,而不是与“名称”的互换。

Both are pretty common.

In my observation, Name is used more frequently for an object with an internal name or for business objects that naturally has a Name property (such as a person). For examples consider MemberInfo.Name and IIdentity.Name. Files are generally considered to have a "filename", and Names often serve the purpose of being at least a part of the object's identity.

Title is used more often to refer to a User Interface Control object or a business object that naturally has a title, like an article.

Personally, I think of a Title as being something that is human-readable, where as a Name is more of a locally scoped identifier that may or may not be human-readable. (I don't mean that the name has to be completely unique, but in many cases, it is - Either way, it tends to provide some identification in its use-context). I conceptually think of "Title" as closer to being interchangeable with "Label" than it is with "Name".

半世蒼涼 2024-11-06 08:44:36

这可能不是一个 C# 问题,而是一个常识问题,适用于计算机以外的许多其他领域:

class Author
{
  string Name{..};
}

class Book
{
  string Title{..};
}

This may not be a C# question but a common sense question applicable to many other areas beyond computers:

class Author
{
  string Name{..};
}

class Book
{
  string Title{..};
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文