What is difference between out and ref in c#?



What is difference between out and ref in c#?..

Answer / Gaurav Agrawal

In C#, both 'out' and 'ref' are used to pass variables by reference. However, a variable declared with 'out' must be explicitly assigned before it leaves the function, while a variable declared with 'ref' can have its initial value passed into the function, or it can be initialized within the function itself.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Sharp Interview Questions

Can you create sealed abstract class in c#?

1 Answers  


What is an iqueryable in c#?

1 Answers  


Can a struct have a default constructor (a constructor without parameters) or a destructor in c#?

1 Answers  


What is mvc pattern in c#?

1 Answers  


How to find out that the code is written as managed or un-managed code?

1 Answers   Amazon,


Explain the functionalities of satellite assembly?

1 Answers   Siebel,


What is function and method in c#?

1 Answers  


What is the use of protected in c#?

1 Answers  


what are the different ways to cleaning up objects?

2 Answers   Wipro,


What is difference between virtual and override in c#?

1 Answers  


what is IEquatable

1 Answers   Wipro,


why do we use Overloading, Overriding, Boxing, Unboxing, and what is the use of these ?

3 Answers   eXensys,


Categories