Anyone can point out the pros and cons of the out parameter. When it is preferred to use out parameter rather than just to return a value.
Out parameters effectively allow you to return multiple values from a method, and this is generally preferable to returning an arbitrary struct or tuple which contains multiple values.
One might argue that it's easier to overlook the possible side effects of a function which uses an out parameter, as it departs from the traditional 'multiple parameters, one return value' model. But I honestly think that the out keyword coupled with a method post-condition makes the programmer's intention quite clear.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With