C# Convert currency to string, remove decimal point but keep decimals, prepend 0s to have fixed width

You can use string.Format() with custom format specifiers. See details here.

double dollars = 38.50;   // your value
int temp = (int)(dollars * 100);   // multiplication to get an integer
string result = string.Format("{0:000000000}", temp);

// Output: 000003850

Leave a Comment