Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

ref and out parametes

This is a discussion on ref and out parametes within the C# forums, part of the Software Development category; what is difference between ref and out parameter?...

Go Back   Geeks Talk > Software Development > C#
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 09-01-2009
Junior Member
 
Join Date: Jun 2009
Posts: 14
Thanks: 0
Thanked 1 Time in 1 Post
ashina1111 is on a distinguished road
ref and out parametes

what is difference between ref and out parameter?
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-02-2009
Junior Member
 
Join Date: Nov 2007
Posts: 26
Thanks: 2
Thanked 4 Times in 4 Posts
shilpa.c is on a distinguished road
Re: ref and out parametes

Hi,

If you are passing variable as a Reference parameters, only assigned variables can be passed, it won't allow you to pass unassigned variables.
When you are passing as a out parameters you can pass unassigned variables as a parameters to method, values should be assigned in the method itself.

For Example
Reference parameters
public static void Method(ref int a,ref int b)
{
..........
}
public static void Main()
{
int a=12,b=2;
Method(ref a,ref b);
}

Out parameters
public static void Method(out int a,out int b)
{
a=10;
b=90;
....
}
public static void Main()
{
int a,b;
Method(out a,out b);
}
Reply With Quote
  #3 (permalink)  
Old 09-02-2009
Junior Member
 
Join Date: Jun 2009
Posts: 14
Thanks: 0
Thanked 1 Time in 1 Post
ashina1111 is on a distinguished road
Re: ref and out parametes

thanks shilpa.c
Reply With Quote
Reply

  Geeks Talk > Software Development > C#

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -4. The time now is 01:11 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved