.NET FAQs Unleashed!
 
    
    

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

1) out parameters return compiler error if they are not assigned a value in the method. Not such with ref parameters.

2) out parameters need not be initialized before passing to the method, whereas ref parameters need to have an initial value before they are passed to a method.

Protected Internal  Array  Sort Array  Throw  Multiple Catch  Polymorphism  Inheritance  Session Viewstate  Autogenerate  ReadOnly  Sealed Class  Sealed Method  Multiple Interfaces  Overloading  Overloaded Constructors  Generics  Main  Case Sensitive  Console  Specifier  Return Type  SetCommandLineArgs  System Environment  New  Default Values of Types Compiler Error Constant Variable Const Const - ReadOnly Parameter Modifier Out Ref Interface Interface Reference, is, as System.Collection

More Interview Questions...