User Id :    Password :      New Member   Forgot Password  
Topic: How do you pass by reference rather than by value in C#?
Sachin Jain
11 Oct 2010 at 04:39 AM
How do you pass by reference rather than by value in C#?
Re: How do you pass by reference rather than by value in C#?
Najmul Hoda
11 Oct 2010 at 11:41 PM

By default C# passes parameters by value. To make it pass by reference, keywords ref and out can beused. Difference between them is that ref parameter needs to be initialised, as below

For Ref:
int itot = 20;
Add(10, ref itot);
For out:
Add(10, out itot);
No need of initializing the parameter in case of out.

Total Replies: 1
 
Featured Text Ad

Featured Ad