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

Are there constructors in c sharp?

0 Answers  


Explain the constructor in c#.

0 Answers  


What is the purpose of static?

0 Answers  


Define multicast delegate in c#?

0 Answers  


What is the advantage of dependency injection?

0 Answers  


I want to single value if you give any integer value. Below are examples  1. Input: 123  Output: 6 2. Input: 99   9+9=18   1+8  Output: 9 How to get above output?

1 Answers   AxSys,


Why we use get set in c#?

0 Answers  


What is “using” statement in c#?

0 Answers  


What is an assembly qualified name

0 Answers  


Can abstract class be sealed in c#?

0 Answers  


What are annotations in c#?

0 Answers  


Please write a program to display “welcome to bestinterviewquestion.com” in c#?

0 Answers  


Categories