C# out parameter performance

后端 未结 6 1644
执笔经年
执笔经年 2020-12-14 16:25

Do out parameters in C# have any performance implications I should know about? (Like exceptions)

I mean, is it a good idea to have

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-14 17:18

    Not a performance issue, but something that came up earlier - you can't use them with variance in C# 4.0.

    Personally, I tend to use out parameters a fair amount in my private code (i.e. inside a class, having a method that returns multiple values without using a separate type) - but I tend to avoid them on the public API, except for the bool Try{Something}(out result) pattern.

提交回复
热议问题