When I first ran into this problem, I though I was crazy and that I was just missing the obvious answer. But after an hour of Google searching I'm out of ideas.
I'm trying to format a number that the user types in so that it has commas in the right places (at the thousands, millions, etc), but also allow for decimals IF THERE ARE ANY.
So far I've found Decimal.ToString("N"). which works fine for the thousands separator but only allows for a fixed number of decimal points. I need to be able to have no decimal points if the number is an integer, and any number of decimal points is the number is a decimal.
Here are some examples of user input and how I want them to come out:
12 -> 12
12.5 -> 12.5
1000 -> 1,000
1000.5 -> 1,000.5
1000.567 -> 1,000.567
123123123.45678 -> 123,123,123.45678
Is there any way to get the desired format?