NumberFormatter.Format(string) - YiZhang-Paul/Mock_Up_Calculator GitHub Wiki
Namespace: FormatterClassLibrary
Description: Format a number represented as string to include thousands separators.
| Parameters | Description |
|---|---|
| number<string> | number to be formatted, represented as string |
| Returns | Description |
|---|---|
| string | formatted number |
| Exceptions | Cause |
|---|---|
| ArgumentNullException | number is null |
| FormatException | number is empty or does not represent valid number |
| OverflowException | number is larger than decimal.MaxValue |
Examples:
var formatter = new NumberFormatter();
Console.WriteLine(formatter.Format("100")); //100
Console.WriteLine(formatter.Format("1000")); //1,000
Console.WriteLine(formatter.Format("1000000")); //1,000,000
Console.WriteLine(formatter.Format("-1000000.999")); //-1,000,000.999