Getting Started with Adobe After Effects - Part 6: Motion Blur
A collection of quick technology learning tips from what people around you learn every day

The difference between out and ref in C-sharp

Aug 1 2011 5:51AM by Kirti M.Darji   

Often people confuse with "ref" and "out". However, these are designed for different purpose.

Ref: 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.

Out: 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.

Read More..   [32134 clicks]

Published under: Microsoft .NET Tips ·  ·  ·  · 


Kirti M.Darji
10 · 16% · 4980
2
 
1
 
 
0
Incorrect
 
0
Interesting
 
0
Forgotten



Submit

2  Comments  

  • Hi,

    Very nice post. I edited this a bit. Is it looks ok?

    commented on Aug 1 2011 5:16AM
    Ramireddy
    2 · 41% · 12972
  • Great Thank you

    commented on Aug 1 2011 6:30AM
    Kirti M.Darji
    10 · 16% · 4980

Your Comment


Sign Up or Login to post a comment.

"The difference between out and ref in C-sharp" rated 5 out of 5 by 2 readers
The difference between out and ref in C-sharp , 5.0 out of 5 based on 2 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]