I am using c#.
I have a method that outputs multiple values. I am aware of out but this is a reference type.
Is there anything equivalent to value type but that can also output multiple values from a method. With the reference type, the values are also changed outside of the method so I like to prevent.
out
It’s not clear what you mean.
outisn’t a type at all – it’s a decorator for parameters. You can use it with reference types or value types:So you can use
outeither way. However, I would strongly advise you not to do so. You can use theTuplefamily of types for ad hoc multiple values, but if the returned values are actually related, you should consider encapsulating them into a separate type, and returning a value of that type.