public static string Format(object value, int decimalDigits, int decimalScale, bool displayThousandSeperator, bool displayEmptyForZero) { string result; if (value == null) { result = string.Empty; } else if (value.GetType() == typeof(string)) { result = (string)value; } else { decimal num = System.Convert.ToDecimal(value); if (num != 0m) { if (decimalDigits > 0) { result = NumberUtils.Format(NumberUtils.Round(num, decimalDigits), "n" + decimalDigits, displayThousandSeperator); } else if (decimalScale > 0) { num = NumberUtils.Round(num, decimalScale); result = (displayThousandSeperator ? NumberUtils.FormatWithThousandSeperator(num, decimalScale) : NumberUtils.Format(num)); } else if (displayThousandSeperator) { result = NumberUtils.FormatWithThousandSeperator(num, 8); } else { result = NumberUtils.Format(num); } } else { result = (displayEmptyForZero ? string.Empty : NumberUtils.Format(num)); } } return(result); }
public static string Format(object value, int decimalDigits, int decimalScale) { return(NumberUtils.Format(value, decimalDigits, decimalScale, false, false)); }
public static string Format(object value) { return(NumberUtils.Format(value, 0, 8)); }