Odd return syntax statement

后端 未结 2 1175
刺人心
刺人心 2020-12-02 12:57

I know this may sound strange but I don\'t know even how to search this syntax in internet and also I am not sure what exactly means.

So I\'ve watched over some More

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-02 13:24

    Consider the simpler example

    void Main()
    {
        Console.WriteLine(Foo()); // Prints 5
    }
    
    public static int Foo()
    {
        return _();
    
        // declare the body of _()
        int _()
        {
            return 5;
        }
    }
    

    _() is a local function declared within the method containing the return statement.

提交回复
热议问题