.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Code Snippets >> Visual Studio >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Use of out parameter in C#

Posted By:Abhisek Panda       Posted Date: October 27, 2009    Points: 10    Category: Visual Studio    URL: http://www.dotnetspark.com  

out Parameter:

When out parameter is used inside the method declaration and call initialisation is not compulsory inside the main() method. It can be initialised inside the function declaration.

class Demo


public int Change(out int i)



return i * i;



class Change


static void main(string a[])


Demo d=new Demo();

int a;

int r= d.Change(out a);





In this program we are declaring a variable a inside the main method and passing it to the Change method.
d.Change(out a);
Then a receives value from i=5 inside the Change().
You have to use out in the method and also when calling the method.


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend