edjournal/Credits.cs

21 lines
714 B
C#
Raw Normal View History

2021-08-25 18:24:44 +02:00
using System.Globalization;
namespace EDJournal {
public class Credits {
public static string FormatCredits(int amount) {
var format = CultureInfo.CurrentCulture.NumberFormat;
2021-08-27 22:15:56 +02:00
format.NumberGroupSeparator = ",";
format.NumberGroupSizes = new int[1] { 3 };
2021-08-25 18:24:44 +02:00
if ((amount % 1000000) == 0) {
amount /= 1000000;
return string.Format("{0}M CR", amount.ToString(format));
} else if ((amount % 1000) == 0) {
amount /= 1000;
return string.Format("{0}K CR", amount.ToString(format));
}
return string.Format("{0} CR", amount.ToString(format));
}
}
}