0

If I got decimal number like 14.50 and I want to be represented like decimal 10.2

0000000014.50

how can I do this?

Thank you

user1765862
  • 13,635
  • 28
  • 115
  • 220

2 Answers2

4

Use custom numeric format string:

var value = 14.50m;

string valueString = value.ToString("0000000000.00");

0 is a placeholder: Replaces the zero with the corresponding digit if one is present; otherwise, zero appears in the result string.

MarcinJuraszek
  • 124,003
  • 15
  • 196
  • 263
0

If you don't have an issue with the data type being converted to string then you could use Padding in c#.

Refer the link below :

http://msdn.microsoft.com/en-us/library/66f6d830(v=vs.100).aspx