2
Answers

Formatting a returned value of type Decimal

Photo of Guest User

Guest User

13y
1.4k
1
Hi

I have a GetTotal method which is of Return Type Decimal.

When I request the Return Value of this method like so

decimal amount = GetTotal();

I get a numeric value as expected eg 30.

What I need to do is assign the return value\result of the amount variable in order to set a PayPal variable. However the format needs to be exact for it to work.

I was looking at using either the {0:F2} to format the decimal (as PayPal requires the "0.00" format) and then use concatenation like so:-

"&paypalamount=" + String.Format("{0:F2}", amount);

I wondered if this looks right as it doesnt appear to work?

Thanks

Steven

Answers (2)