Marc... I agree that using a single out parameter is useful as in
TryParse, but a more object oriented approach is simpler and less error
prone for multiple parameters. For instance:
public Mortgage.Calculation Calculate(Mortgage.Parameters m)
{
return Calculate(m.Principal, m.Interest, m.Months, m.Payment,
m.Target);
}
Is easier to use and less error prone than:
private bool TryCalculate(Mortgage.Parameters p,out double
principal,out double interest,out int months,out double payment,out int
target)
{
Mortgage.Calculation result= this.Calculate(p.Principal,
p.Interest, p.Months, p.Payment, p.Target);
principal = result.Principal;
interest = result.Interest;
months = result.Months;
payment = result.Payment;
target = result.Target;
return result.IsValid();
}
Regards,
Jeff
>But yes; in many cases "ref" on a reference type parameter is due to
misconceptions. In contrast, "out" is IMO becoming more mainstream and
more useful that "ref", largely due to adopting the TryGetValue and
TryParse signatures from the 2.0 classes.<
*** Sent via Developersdex
http://www.developersdex.com ***