什么是时间最长法律语句块,你可以只用C#的关键字做什么呢?

StackOverflow https://stackoverflow.com/questions/672977

  •  21-08-2019
  •  | 
  •  

我在写在C#一些代码,我发现自己写:

return new MyClass(...

时,我注意到,无论是returnnew均为C#关键字。所以,我不知道什么是C#关键字的时间最长的法律序列。所有我能想到的是:

internal static override void MyFunc(...

在哪里internal static override void都是关键字。你能想到的关键字较长序列?

请注意:这确实没有点到问题。我只是希望能倒在火多一些乐趣: - )

有帮助吗?

解决方案

有关6:

new protected internal unsafe virtual decimal Foo() {...}

修改为7:

new protected internal unsafe virtual extern decimal Foo();

如果我们允许括号和大括号...

(的编辑 “锁定”, “新的对象()”, “为” 和 “字符串” 中贡献的其他人;见注释)

decimal Bar() {
    lock (new object() as string) {
        if (true) {
            checked {
                unsafe {
                    try {
                        do {
                            return default(decimal);
                            unchecked {break;}
                            continue;
                        } while (false);
                    }
                    catch { throw; }
                    finally { }
                }
            }
        }
    }
}

其他提示

我想这是无限:

return null as string as string as string as string as string....

下面是可以,只要你想另一种情况:

do do do do do do do do do do do do do do do // ...
while(x) while(x) while(x) while(x) while(x) // ...

通过上下文关键字,你也可以有

await await await await await await await // ...
internal protected static volatile string foo = "bar";

这是5。

一个多种变异与方法定义(我的同事发现的):

protected internal override sealed unsafe async void await() { ... }

在一排使8个关键字。使用的事实,await是一个上下文关键字,因此它可以用于方法名被重复使用。

我可以欺骗?

internal protected static volatile StringBuilder @string = 
  new StringBuilder(int.Parse("12"));

使用的事实,我可以使用关键字或其它保留术语作为变量名,如果我以@前面加上它 - 如果允许的StringBuilder的复制在9进来

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top