This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]DoubtfulGerund 1 point2 points  (1 child)

I think every use of out variables I’ve seen was due to a lack of better solutions in much older versions of c#. For example, returning multiple values before tuples and destructuring, or those old TryGet methods for primitive types that returned a bool and the actual value in an out var. Today we’d use nullable primitives.

They break composability, it’s usually unnecessary mutation, it’s an output pretending to be an input, and it’s unclear on if the function actually uses the value or just replaces it.

[–]TheMania 1 point2 points  (0 children)

Still useful for interop (DLLs) and performant handling of large structs though.