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

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


Please Help Members By Posting Answers For Below Questions

What is thread safe in c#?

659


How does it work?

679


Int map to which .net types?

750


What is session c#?

691


What is garbage collector and where should you use in .NET?

722


in the nunit test framework, which attribute must adorn a test class in order for it to be picked up by the nunit gui?

906


What do u meant by "SBI" of an object?

743


What is Custom attribute? How to create? If I'm having custom attribute in an assembly, how to say that name in the code?

705


What is the predicate of a sentence?

656


What is the difference between Static, Const and read only?

822


What is expression tree in c#?

686


What is the importance of closing an ado.net application?

677


Define xslt.

728


how dot net compiled code will become platform independent?

731


What is super class in c#?

626