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 used ref keyword in c#,and how we used it?

Answer Posted / raj093300

ref keyword casues an argument to be passed by reference,not
by value.The effect of passing by reference is that any
change to the parameter in the method is reflected in
undergoing argument variable in the calling argument.The
value of a reference parameter is always the same as the
value of the underlying argument variable...

AS SHOWN IN THIS EXAMPLE...

class sample
{
public static int value(ref int a)
{
a=100;
return a;
}
static void Main()
{
int b=22;
int c=value(ref b);
Console.WriteLine("Output was " +c);
Console.Readkey();
}
}

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is cshtml?

942


How can we set class to be inherited, but prevent the method from being over-ridden?

939


Why do we use Design Pattern in C#?

976


Which debugging tools you can use in the .NET ssSDK?

935


How do I move from one form to another in c#?

835


What is the difference between CreateObject() and GetObject()?

1027


What is the best dependency injection c#?

832


What are extender provider components?

840


List some of the classes used by system.data namespace?

787


What is distribute by in hive?

991


What is arraylist class in c#?

1018


Explain about Destructor method?

900


What does namespace mean?

888


Can c# inherit multiple classes?

908


What do you mean by “finalize” and “finally” methods in c#?

855