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



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

Answer / Mr Sambhu Kumar

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

Explain About Postback

1 Answers   BirlaSoft,


What is a delegate?

5 Answers   Siebel Systems,


What is the difference between delegates and events in c#?

1 Answers  


what are delegates? How you used then in your project?

10 Answers   Hawk Eye, IndiaTimes, Kanbay,


What is datacontract in c#?

1 Answers  


How does the clr work?

1 Answers  


if a method is marked as protected internal who can access it?

1 Answers   Siebel Systems,


How do namespaces work?

1 Answers  


What is parallel programming in c#?

1 Answers  


Is java better than c sharp?

1 Answers  


What?s the difference between // comments, /* */ comments and /// comments?

2 Answers   Intel, Visual Soft,


OOPs concept ?

1 Answers   iGate, MMTS,


Categories