What is the value of an anonymous unattached block in C#?

后端 未结 10 1518
谎友^
谎友^ 2021-01-11 20:43

In C# you can make a block inside of a method that is not attached to any other statement.

    public void TestMethod()
    {
        {
            string x          


        
10条回答
  •  抹茶落季
    2021-01-11 20:52

    Even if it was actually useful for any reason (e.g. variable scope control), I would discourage you from such construct from the standpoint of good old code readibility.

提交回复
热议问题