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
Can a constructor be static in c#?
Why dictionary is faster than list?
Why can't we use a static class instead of singleton?
Can a struct inherit from an interface in c#?
What are the types of comment in c# with examples?
Illustrate serialization?
Why do we use dataset in c#?
What are the Types of instancing properties and explain each. Explain the difference between multiuse,singleuse and globalmultiuse and which is default
What is the difference between a variable and a literal?
What is querystring in c#?
How to find methods of a assembly file (not using ILDASM)?
What is the advantage of extension method in c#?
What is a partial method?
What is Inheritance in C#?
What is action c#?