edjournal/Credits.cs

22 lines
801 B
C#

using System.Globalization;
namespace EDJournal {
public class Credits {
public static string FormatCredits(int amount) {
var format = new CultureInfo(CultureInfo.CurrentCulture.Name, true).NumberFormat;
format.NumberGroupSeparator = ",";
format.NumberGroupSizes = new int[1] { 3 };
format.NumberDecimalDigits = 0;
if ((amount % 1000000) == 0) {
amount /= 1000000;
return string.Format("{0}M CR", amount.ToString("N", format));
} else if ((amount % 1000) == 0) {
amount /= 1000;
return string.Format("{0}K CR", amount.ToString("N", format));
}
return string.Format("{0} CR", amount.ToString("N", format));
}
}
}