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 |
Are there constructors in c sharp?
Explain the constructor in c#.
What is the purpose of static?
Define multicast delegate in c#?
What is the advantage of dependency injection?
I want to single value if you give any integer value. Below are examples 1. Input: 123 Output: 6 2. Input: 99 9+9=18 1+8 Output: 9 How to get above output?
Why we use get set in c#?
What is “using” statement in c#?
What is an assembly qualified name
Can abstract class be sealed in c#?
What are annotations in c#?
Please write a program to display “welcome to bestinterviewquestion.com” in c#?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)