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 use of 'as' Keyword in C# ?

0 Answers   HCL,


Explain lock, monitors, and mutex object in threading.

0 Answers  


Where is the keyword void used?

0 Answers  


Explain the difference between const and static read-only?

0 Answers  


What is double c#?

0 Answers  


Difference between value and reference type. What are value types and reference types?

0 Answers  


What is the functionality of break and continue in Visual Studio?

2 Answers   JPMorgan Chase,


Trace the O/p for a program on inheritance and Polymorphism. 3 classes A,B,C A with two methods public virtual SomeMethodA public virtual SomemoreMethodA B:A overide virtual SomeMethodA C:B new Method SomeMethodA override SomeMoreMethodA main method { b new instance of B b.SomeMethodA b.SomeMoreMethodA b1 new instance of C b1.SomeMethodA b1.SomeMoreMethodA }

1 Answers  


How is the memory managed in C#.

1 Answers  


what is collections in .net? why we use?

0 Answers  


What is the usage of OLE?

0 Answers   Wipro,


Explain jagged arrays in c#?

0 Answers  


Categories