English 中文(简体)
C#中的职能执行者命令
原标题:Order of function modifiers in C#

我愿知道,在C#.,即,是否有确定职能执行者顺序的标准。

public static void Method()
{}

static public void Method()
{}

这两项工作都是良好的。

一、导 言

public void static Method()
{}

我收到以下错误:

Member modifier static must precede the member type 以及name

以及

方法必须有返回类型。

最佳回答

方法声明必须始终遵循这一模式:

[modifiers] returnType methodName([parameters])

没有关于反叛者命令的规则,但他们必须总是在返回类型之前。

我不认为存在任何标准秩序,人们也这样做了。 我本人更喜欢首先对出入模块(public, private, 等等),然后是static modifier (如果有的话), 接着是virtual,abstract modifier (如果有的话)。

See C# spec for details (§ 10.6)

问题回答

问题是<代码>撤销。 它是固定的,是返回类型。 所有叛乱分子都必须回到返回的类别。

我确信,is是命令真正的支持者的公约,但我不知道有哪份文件。

我总是首先写出无障碍(公众等)。

没有对手法者制定具体命令。

以下是C#标准规格的正式图表......

Methods are declared using method-declarations:
method-declaration:
method-header method-body

method-header:
attributesopt method-modifiersopt partialopt return-type member-name type-parameter-listopt ( formal-parameter-listopt ) type-parameter-constraints-clausesopt

****method-modifiers:****
new
public
protected
internal
private
static
virtual
sealed
override
abstract
extern
return-type:
type
void
member-name:
identifier
interface-type . identifier





相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

pdo database abstraction

Can someone help me to see what is going wrong with this setup I build the @sql query in the function below like this. The extra quotes are setup in the conditions array. $sql .= " WHERE $...

I wish I could correlate an "inline view"

I have a Patient table: PatientId Admitted --------- --------------- 1 d/m/yy hh:mm:ss 2 d/m/yy hh:mm:ss 3 d/m/yy hh:mm:ss I have a PatientMeasurement table (0 to ...

Syntax help! Php and MYSQL

Original: $sql = "SELECT DATE(TimeAdded) AS Date, $column_name FROM Codes ORDER BY TimeAdded ASC"; Altered: $sql = "SELECT DATE("m", TimeAdded ) AS Date, ColumnName FROM TableName ORDER BY ...

Is this code Equivalent

I am not a fan of the following construction if (self = [super init]) { //do something with self assuming it has been created } Is the following equivalent? self = [super init]; if (self != ...

热门标签