Why are 'out' parameters in .NET a bad idea?

后端 未结 22 2906
余生分开走
余生分开走 2020-12-25 10:54

Why are \'out\' parameters in .NET a bad idea?

I was recently asked this, but I had no real answer besides it\'s simply unnecessarily complicating an application. Wh

22条回答
  •  不知归路
    2020-12-25 11:28

    I would say the answer you gave is about the best there is. You should always design away from out parameters if possible, because it usually makes the code needlessly complex.

    But this is true of just about any pattern. If there is no need for it, don't use it.

提交回复
热议问题