C#抽象类命名约定

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16857991/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 07:57:37  来源:igfitidea点击:

C# abstract class naming convention

c#.netnaming-conventions

提问by binard

In C#, the interface naming convention is I<myInterfaceName>(ex: IList).

在 C# 中,接口命名约定是I<myInterfaceName>(例如:)IList

Are there any naming conventions for abstract classes?

抽象类是否有任何命名约定?

If there aren't, what are the main recommendations?

如果没有,主要的建议是什么?

回答by bpoiss

Normally, there is no suffix/prefixused when naming abstract classes, unlike interfaces, which have the prefix "I". Just give your class a name that describes what it is for, in a short precise way.

通常,在命名抽象类时不使用后缀/前缀,这与接口具有前缀“I”不同。只需为您的班级命名,以简短准确的方式描述其用途。

回答by jason

Are there a naming convention for abstract class ?

抽象类是否有命名约定?

No, there are no conventions here. There are some commonways of denoting an abstract base class. The most common I've seen is to use the suffix Base. Personally, I do not like this convention, and the Framework guidelinesrecommend against it.

不,这里没有约定。有一些表示抽象基类的常用方法。我见过的最常见的是使用后缀Base. 就我个人而言,我不喜欢这个约定,并且框架指南建议反对它。

And if there aren't what is the mains recommandations ?

如果没有什么是电源推荐?

A good, general name that describes what the class is modeling, just like any other class name. So Shapeand then Polygonand then RegularPolygonso on.

一个很好的通用名称,用于描述类正在建模的内容,就像任何其他类名称一样。因此,Shape然后PolygonRegularPolygon等。