Return multiple values to a method caller

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

    Future version of C# is going to include named tuples. Have a look at this channel9 session for the demo https://channel9.msdn.com/Events/Build/2016/B889

    Skip to 13:00 for the tuple stuff. This will allow stuff like:

    (int sum, int count) Tally(IEnumerable list)
    {
    // calculate stuff here
    return (0,0)
    }
    
    int resultsum = Tally(numbers).sum
    

    (incomplete example from video)

提交回复
热议问题