When should we use an out
parameter in C#?
For example
bool TryGetValue(out object value);
vs.
class ReturnType
{
public bool Found {get;set;}
public object Value {get;set;}
}
ReturnType TryGetValue();
Apart from reducing the number of lines of code, when should an out
parameter to be used and when it should be returned as return type?