This program will help you to add dollars sign before a number using C#. You can add another currency sign but you need to pass appropriate culture information. for example for us dollars pass en-US
C# Sample code to add $
using System;
using System.Globalization;
namespace MyApp
{
class formatting_class
{
static void Main()
{
decimal Money = 100.20M;
Console.WriteLine(Money.ToString("c", new CultureInfo("en-US")));
Console.Read();
}
}
}
No comments:
Post a Comment