What is the longest legal statement block you can make with only C# keywords?

后端 未结 8 1452
粉色の甜心
粉色の甜心 2020-12-28 16:39

I was writing some code in C#, and I found myself writing:

return new MyClass(...

when I noticed that both the return and the

8条回答
  •  没有蜡笔的小新
    2020-12-28 17:25

    For 6:

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

    Edit for 7:

    new protected internal unsafe virtual extern decimal Foo();
    

    If we allow brackets and braces...

    (edited the "lock", "new object()", "as" and "string" were contributed by others; see comments)

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

提交回复
热议问题