what is used ref keyword in c#,and how we used it?
Answers were Sorted based on User's Feedback
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 |
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 |
What is the difference between interface and functional interface?
What is the difference between properties and indexer in c#?
What?s an abstract clas?
how to implement a web service in .net
code for arranging given number in possible permutation ways ex:123,321,312,132,231,213.
What is indexer c#?
Explain the concepts of cts and cls(common language specification).
What are jagged arrays used for?
Describe how a .net application is compiled and executed
Name which controls do not have events?
Give examples for value types?
7. C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to keep the no parameter one. How many constructors should I write?