Method should return multiple values

后端 未结 7 1098
执笔经年
执笔经年 2020-12-19 09:10

Hii

I have method in C#, I have to return multiple values from that method with out using collections like arrays. Is there any reliable way ?

7条回答
  •  既然无缘
    2020-12-19 09:28

    If you are using .NET 4.0 you can use one of the generic Tuple classes to return multiple values from a method call. The static Tuple class provides methods to create Tuple objects. So you do not have to define your own return type for the method.

    public Tuple Execute()
    {
      return new Tuple("Hello World", 2);
    }
    

提交回复
热议问题