Two Decimal places using c#
Solution 1:
Your question is asking to display two decimal places. Using the following String.format will help:
String.Format("{0:.##}", Debitvalue)
this will display then number with up to two decimal places(e.g. 2.10 would be shown as 2.1 ).
Use "{0:.00}", if you want always show two decimal places(e.g. 2.10 would be shown as 2.10 )
Or if you want the currency symbol displayed use the following:
String.Format("{0:C}", Debitvalue)
Solution 2:
Use Math.Round()
for rounding to two decimal places
decimal DEBITAMT = Math.Round(1156.547m, 2);
Solution 3:
If you want to round the decimal, look at Math.Round()