Return multiple values to a method caller

前端 未结 26 2314
故里飘歌
故里飘歌 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:35

    In C# 7 and above, see this answer.

    In previous versions, you can use .NET 4.0+'s Tuple:

    For Example:

    public Tuple GetMultipleValue()
    {
         return Tuple.Create(1,2);
    }
    

    Tuples with two values have Item1 and Item2 as properties.

提交回复
热议问题