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
Why should I use interface in c#?
What is the use of properties window?
What is lambda expression in c#?
What exception can an overridden method throw in comparison with the method it is overriding?
What happens if a static constructor throws an exception?
What are "class access modifiers" in C#?
What is list array in c#?
What are primitive types in c#?
Name the control which cannot be placed in mdi?
Is visual c# free?
Does main have to be static c#?
What is the difference between asp net and c#?
What is multicast delegate in c# ?
Explain the importance and use of each, version, culture and publickeytoken for an assembly.
What is the difference between returning iqueryable vs ienumerable?