Skip to content

Commit d0df169

Browse files
committed
Added documentation to CurrencyUtils.cs
1 parent def3587 commit d0df169

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Utils/DecimalUtils.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@ namespace Utils
55
{
66
public static class DecimalUtils
77
{
8-
private static NumberFormatInfo whitespaceSeparatorNfi = (NumberFormatInfo)CultureInfo.InvariantCulture.NumberFormat.Clone();
8+
// define white space separator number format, it is to be used in all format methods on this class
9+
private static readonly NumberFormatInfo WhitespaceSeparatorNf = (NumberFormatInfo)CultureInfo.InvariantCulture.NumberFormat.Clone();
10+
911
static DecimalUtils()
1012
{
11-
whitespaceSeparatorNfi.NumberGroupSeparator = " ";
13+
// make the number format use whitespace as thousands separator
14+
WhitespaceSeparatorNf.NumberGroupSeparator = " ";
1215
}
1316

14-
public static string FormatTrimZeros(decimal value) => value.ToString("#,0.#############", whitespaceSeparatorNfi);
17+
public static string FormatTrimZeros(decimal value) => value.ToString("#,0.#############", WhitespaceSeparatorNf);
1518

16-
public static string FormatTwoDecimalPlaces(decimal value) => value.ToString("#,0.00", whitespaceSeparatorNfi);
19+
public static string FormatTwoDecimalPlaces(decimal value) => value.ToString("#,0.00", WhitespaceSeparatorNf);
1720

18-
public static string FormatFiveDecimalPlaces(decimal value) => value.ToString("#,0.00000", whitespaceSeparatorNfi);
21+
public static string FormatFiveDecimalPlaces(decimal value) => value.ToString("#,0.00000", WhitespaceSeparatorNf);
1922

2023
public static string FormatTwoDecimalPlacesWithPlusSign(decimal value) =>
2124
(value > 0 ? "+" : "") + FormatTwoDecimalPlaces(value);

0 commit comments

Comments
 (0)