In .NET, I need to convert a decimal amount (money) to a numbers-only string, i.e: 123,456.78 -> 12345678
I thought
var dotPos = amount.ToString().L
You could do it like this:
var amountString = string.Join("", amount.Where(char.IsDigit));
Using the char.IsDigit
method will protect you from other unknown symbols like $
and will also work with other currency formats. The bottom line, you don't know exactly what that string will always look like so it's safer this way.