-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGilFormatter.cs
More file actions
33 lines (28 loc) · 1 KB
/
Copy pathGilFormatter.cs
File metadata and controls
33 lines (28 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System.Globalization;
namespace MatheMann;
// Number format for the Copy buttons (separate from the on-screen display format).
public enum GilFormat
{
German, // 1.234.567
International, // 1,234,567
Raw, // 1234567
}
public static class GilFormatter
{
private static readonly CultureInfo De = CultureInfo.GetCultureInfo("de-DE");
private static readonly CultureInfo En = CultureInfo.GetCultureInfo("en-US");
// Labels for the settings dropdown, in enum order.
public static readonly string[] Labels =
{
"German (1.234.567)",
"International (1,234,567)",
"Raw (1234567)",
};
public static string Format(ulong value, GilFormat format) => format switch
{
GilFormat.German => value.ToString("N0", De),
GilFormat.International => value.ToString("N0", En),
GilFormat.Raw => value.ToString(CultureInfo.InvariantCulture),
_ => value.ToString("N0", De),
};
}