Return multiple values to a method caller

前端 未结 26 2308
故里飘歌
故里飘歌 2020-11-21 21:57

I read the C++ version of this question but didn\'t really understand it.

Can someone please explain clearly if it can be done and how?

26条回答
  •  情书的邮戳
    2020-11-21 22:40

    If you mean returning multiple values, you can either return a class/struct containing the values you want to return, or use the "out" keyword on your parameters, like so:

    public void Foo(int input, out int output1, out string output2, out string errors) {
        // set out parameters inside function
    }
    

提交回复
热议问题