public static string getFormattedValue(string Format, decimal _value) { string _FormattedValue; int NumberOfDecimals; decimal RoundedValue; if (Format != null && Format != "" && Format.Length > 1) { NumberOfDecimals = Format.Substring(1).ToInt32(); if (NumberOfDecimals > 0) { RoundedValue = Math.Round(_value, NumberOfDecimals); _FormattedValue = RoundedValue.ToString(Format); } else { _FormattedValue = _value.ToString(Format); } } else { _FormattedValue = _value.ToString(); } return(_FormattedValue); }
public override string ToString() { return(RoundedValue.ToString(CultureInfo.CurrentCulture.NumberFormat)); }