What are the two keywords used to pass a variable by
reference in c#?
Answers were Sorted based on User's Feedback
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 |
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 |
What is the use of 'as' Keyword in C# ?
Explain lock, monitors, and mutex object in threading.
Where is the keyword void used?
Explain the difference between const and static read-only?
What is double c#?
Difference between value and reference type. What are value types and reference types?
What is the functionality of break and continue in Visual Studio?
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 }
How is the memory managed in C#.
what is collections in .net? why we use?
What is the usage of OLE?
Explain jagged arrays in c#?