/// <summary> /// Retourne le nombre au format litéral choisi /// </summary> /// <param name="format">Format du nombre litéral</param> /// <returns></returns> public string ToString(LiteralNumberFormat format) { string ret = (IsNegative ? "moins " : ""); switch (format) { case LiteralNumberFormat.Normal: ret += IntegralPart + (!string.IsNullOrWhiteSpace(DecimalPart) ? " virgule " + DecimalPart : ""); break; case LiteralNumberFormat.Recommandation1990: ret += IntegralPart.Replace(' ', '-') + (!string.IsNullOrWhiteSpace(DecimalPart) ? " virgule " + DecimalPart.Replace(' ', '-') : ""); break; case LiteralNumberFormat.Money: ret += string.Format("{0} euro{1}", IntegralPart, Math.Abs(integralPart) > 1 ? "s" : "") + ((!string.IsNullOrWhiteSpace(DecimalPart) ? string.Format(" et {0} centime{1}", DecimalPart, Math.Abs(decimalPart) > 1 ? "s" : "") : "")); break; default: break; } return(ret); }
/// <summary> /// Retourne le nombre en lettre /// </summary> /// <param name="number">Le nombre à transcrire</param> /// <param name="format">Le format souhaité</param> /// <returns></returns> public static string ToWord(this byte number, LiteralNumberFormat format) { return(Convert.ToDecimal(number).ToWord(format)); }
/// <summary> /// Retourne le nombre en lettre /// </summary> /// <param name="number">Le nombre à transcrire</param> /// <param name="format">Le format souhaité</param> /// <returns></returns> public static string ToWord(this decimal number, LiteralNumberFormat format) { return(GetWords(number, format == LiteralNumberFormat.Money).ToString(format)); }