What are the two keywords used to pass a variable by
reference in c#?

Answers were Sorted based on User's Feedback



What are the two keywords used to pass a variable by reference in c#?..

Answer / sreekanth m

Two keywords are "ref" and "out".

the difference between them are: In the case of "ref", the
passed argument should be initialized first whereas
for "out", its not mandatory.

Is This Answer Correct ?    10 Yes 1 No

What are the two keywords used to pass a variable by reference in c#?..

Answer / pramod singh

A variable of a reference type does not contain its data
directly; it contains a reference to its data. When you pass
a reference-type parameter by value, it is possible to
change the data pointed to by the reference, such as the
value of a class member. You cannot change the value of the
reference itself; that is, you cannot use the same reference
to allocate memory for a new class and have it persist
outside the block. To do that, pass the parameter using the
ref (or out) keyword. For simplicity, the following examples
use ref.

Is This Answer Correct ?    5 Yes 0 No

Post New Answer

More C Sharp Interview Questions

What is the gac, and where is it located?

1 Answers  


Differentiate between method overriding from method overloading with its functionality?

0 Answers   Siebel,


What is deferred execution in c#?

0 Answers  


Where value types are stored in c#?

0 Answers  


What do you understand by 'access specifiers' in C#?

0 Answers   Genpact,






What is connection pooling in ado.net?

0 Answers  


wt is namespace? wt is the use?

12 Answers  


How can you sort the elements of the array in descending order?

4 Answers  


What does an indexer do?

0 Answers  


Can we use "this" command within a static method?

0 Answers  


How many types of collections are there in c#?

0 Answers  


What is Reflection in .NET? Namespace? How will you load an assembly which is not referenced by current assembly?

0 Answers  


Categories