Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what is reference parameter?
what is out parameters?
what is difference these two?

Answer Posted / dharmendra nonia

A reference parameter contain only reference of variable
instead of value. In reference type parameter if changes
occurs in variable than it affect the original value. But
in out parameter it send only a copy of variable instead of
reference therefore if u change in variable no changes
occur in original value.
For example:-
class Program
{
public void refparameter(ref int a)
{
a += 5;
}
public void outparameter(out int p)
{
p = 20;
}
static void Main(string[] args)
{
Program p = new Program();
int b,c;
Console.Write("Enter a Number:");
b = Int32.Parse(Console.ReadLine());
p.refparameter(ref b);
//After the calling of refparameter it change the value of b
Console.WriteLine("After calling refparameter
method value of B is:{0}",b);
p.outparameter(out c);
Console.WriteLine("After calling the
outparameter method value of C is:{0}",c);
Console.ReadLine();
}
}

Is This Answer Correct ?    6 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between dynamic type variables and object type variables in c#?

882


What is default access modifier for class in c#?

1025


What are the Types of assemblies that can be created in dotnet

1154


What are the types of inheritance in c#?

961


What is default class in c#?

919


How is a strongly-named assembly different from one that isn’t strongly-named?

1055


What are the different types of constructors in c#?

1132


How can you achieve run time polymorphism in C#?

1008


Name the control which cannot be placed in mdi?

888


What is difference between abstract class and interface in c#?

945


What is serialization and deserialization in c# with example?

885


What is the purpose of static?

976


Why do we use readonly in c#?

920


Why do we use virtual methods in c#?

949


windows c# using datagridview in edit form sql server

4091