Return multiple values to a method caller

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

    you can try this "KeyValuePair"

    private KeyValuePair GetNumbers()
    {
      return new KeyValuePair(1, 2);
    }
    
    
    var numbers = GetNumbers();
    
    Console.WriteLine("Output : {0}, {1}",numbers.Key, numbers.Value);
    

    Output :

    Output : 1, 2

提交回复
热议问题