ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

ToUIString

Converts a decimal to a string using the current UI culture

Source

using System.Globalization;

namespace Extensions
{
    public static class DecimalExtensions
    {
         public static string ToUIString(this decimal value)
         {
             return value.ToString(CultureInfo.CurrentUICulture);
         }
    }
}

Example

var amount = 10.25m;
Amount.Text = amount.ToUIString();

Author: Guy Van den Nieuwenhof

Submitted on: 24 jul. 2012

Language: C#

Type: System.Decimal

Views: 5916