Often people confuse with "ref" and "out". However, these are designed for different purpose.
In general when a variable is passed to a method, another copy of that variable will be created and passed to method. "ref" will avoid creating another copy by passing the reference of that variable(alias). If you want your variable to reflect changes inside method, pass it as "ref". So, while passing a "ref" variable, you should initialize it.
In general a method can return only 1 value. If you want to pass more than 1 value from a method, we can use multiple "out" variables. There are few points to remember with "out", It should be initialized in method at least once and it should be initialized before its first time use. So, even when you pass some value as "out". You can't use that value. It means that you can’t use out parameter to pass value into method. but you can use ref parameter to pass value.
Microsoft .NET Tips · · · ·
Very nice post. I edited this a bit. Is it looks ok?
Great Thank you