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?

Answers were Sorted based on User's Feedback



what is used ref keyword in c#,and how we used it?..

Answer / 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

what is used ref keyword in c#,and how we used it?..

Answer / satya

if you want pass parameters by reference then ref keyword
should be used in calling and called methods
void add(ref int x)--- called(formal parameter)
add(ref a)-----calling(actual parameter)
.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Sharp Interview Questions

What you mean by inner exception in c#?

0 Answers  


What is lock statement in C#?

0 Answers   B-Ways TecnoSoft,


how to sort an array in c#

0 Answers   Cognizant,


Which are the access modifiers available in c#?

0 Answers  


What are the valid parameter types we can pass in an Indexer ?

3 Answers   CMC,


What is the use of giving more than one CATCH BLOCK in one TRY block? Directly we can give that catch(Exception e)?Why we go for arrayoutofbound Exception,divided by zero etc..? Explain

2 Answers  


Is lazy thread safe c#?

0 Answers  


Are arrays immutable c#?

0 Answers  


What are Regex / regular expressions ?

0 Answers   QuestPond,


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

0 Answers  


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

0 Answers  


What is the purpose of a constructor in c#?

0 Answers  


Categories