decimal Debitvalue = 1156.547m;
decimal DEBITAMT = Convert.ToDecimal(string.Format("{0:0.00}", Debitvalue));
I have to get only two decimal places but by using this code I am getting 1156.547. Let me know which format I have to use to display two decimal places.
Another option is to use the Decimal.Round Method
The best approach if you want to ALWAYS show two decimal places (even if your number only has one decimal place) is to use
Your question is asking to display two decimal places. Using the following String.format will help:
this will display then number with only two decimal places.
Or if you want the currency symbol displayed use the following:
Use
Math.Round()
for rounding to two decimal placeshere is another approach
I use