Buscar contenidos

jueves, 30 de marzo de 2017

Método extensión para aplicar máscara/moneda C#


Extension Method

    public static string ToMoneyMask(this decimal value)
        {
            //return string.Format(new CultureInfo(MenoyFormat, false), "{0:c0}", value);

            var usCulture = CultureInfo.CreateSpecificCulture("en-US");

            var clonedNumbers = (NumberFormatInfo)usCulture.NumberFormat.Clone();

            clonedNumbers.CurrencyNegativePattern = 2;

            string formatted = string.Format(clonedNumbers, "{0:N}", value);

            return (formatted);

        }

No hay comentarios:

Publicar un comentario