Returning two values, Tuple vs 'out' vs 'struct'

前端 未结 6 1189
傲寒
傲寒 2020-12-24 04:23

Consider a function which returns two values. We can write:

// Using out:
string MyFunction(string input, out int count)

// Using Tuple class:
Tuple

        
6条回答
  •  抹茶落季
    2020-12-24 05:00

    There is no "best practice". It is what you are comfortable with and what works best in your situation. As long as you are consistent with this, there is no problem with any of the solutions you've posted.

提交回复
热议问题