Best practice of using the “out” keyword in C#

后端 未结 10 2119
暗喜
暗喜 2020-12-16 11:53

I\'m trying to formalise the usage of the \"out\" keyword in c# for a project I\'m on, particularly with respect to any public methods. I can\'t seem to find any best practi

10条回答
  •  遥遥无期
    2020-12-16 12:11

    There is a reason that one of the static code analysis (=FxCop) rules points at you when you use out parameters. I'd say: only use out when really needed in interop type scenarios. In all other cases, simply do not use out. But perhaps that's just me?

提交回复
热议问题