Can you please tell me what is the exact use of out
parameter?
Related Question:
What is the differen
The best example of a good use of an out
parameter are in the TryParse
methods.
int result =-1;
if (!Int32.TryParse(SomeString, out result){
// log bad input
}
return result;
Using TryParse
instead of ParseInt
removes the need to handle exceptions and makes the code much more elegant.
The out
parameter essentially allows for more than one return values from a method.