Standard formatting in .NET is sometimes not enough to fill specific requirements. For example, when high-level financial reports from big corporations need to be produced, the numbers dealt-with are generally around hundred of millions. Consider the following report where the scale and the currency (M$) is being displayed in the row header.
| Quarter 1 | Quarter 2 |
| New York (in M$) | 102.76 | 21.40 |
| Florida (in M$) | 32.76 | 67.40 |
In order to achieve this formatting, a straightforward solution would be to apply a scaling factor to the numbers beforehand.
string.Format("{0:N2}", valueToFormat / 1000000);
Sometimes, it is not appropriate nor possible to scale the numbers. In this situation, number scaling using the "," custom specifier could be used. Note the use of two commas since the number to be formatted is divided by 1000 for each comma:
decimal valueToFormat = 1345278000.346M;
string.Format("0:#,#,,", valueToFormat ); // displays 1,345 with the invariant culture