Digital World

15 May, 2005

C# language ref, out parameters debate

out parameters, Ref parameters basically serve the same purpose of returning values from the functions. But out parameters need not be initialized to me a true nomenclature.But ref parameters on the other hand needs to be initialized.
In true sense ref parameters are even more handy at times than the out parameters because ref parameters acts as an in,out parameter. There is wrong conception that the ref parameters has the overhead of initializing.
Illustration I have sales tax calculator for a commodity bought at the price Rs.100.04
main(){
double price = 100.04;
double ultimateprice = 0;
double tax = 0;
tax = calculatetax(price)
calculatesurcharge(tax);
ultimateprice = price + tax;
}
calculatesurcharge(ref Ultimatetax);
No argument on which is better, to me use ref and out parameters at the right place

0 Comments:

Post a Comment

<< Home