What's so bad about ref parameters?

后端 未结 12 691
隐瞒了意图╮
隐瞒了意图╮ 2021-01-11 09:49

I\'m faced with a situation that I think can only be solved by using a ref parameter. However, this will mean changing a method to always accept a ref parameter when I only

12条回答
  •  误落风尘
    2021-01-11 10:11

    This is one of those things that F# or other functional programming languages solve a lot better with returning Tuple values. Its a lot more cleaner and terse syntax. In the book I am reading on F#, it actually points out the C# equivelant of using ref as doing the same thing in C# to return multiple parameters.

    I have no idea if it is a bad practice or there is some underlying "booga booga" about ref parameters, to me they just feel as not clean syntax.

提交回复
热议问题