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
What is cshtml?
How can we set class to be inherited, but prevent the method from being over-ridden?
Why do we use Design Pattern in C#?
Which debugging tools you can use in the .NET ssSDK?
How do I move from one form to another in c#?
What is the difference between CreateObject() and GetObject()?
What is the best dependency injection c#?
What are extender provider components?
List some of the classes used by system.data namespace?
What is distribute by in hive?
What is arraylist class in c#?
Explain about Destructor method?
What does namespace mean?
Can c# inherit multiple classes?
What do you mean by “finalize” and “finally” methods in c#?