Thursday, June 21, 2012

the difference between ref and out in C#

...is that out MUST be set inside of a method that has it in its signature. Otherwise an exception is thrown! Otherwise ref and out are comparable. One may instantiate variable x and variable y in C#, call a method that uses variable x and variable y as a ref variable and an out variable respectively, and then go about using x and y in later code while enjoying the alterations made in the method to the two variables (certainly true of y).

No comments:

Post a Comment