How to format Currency (Pound/Dollar/Euro etc) using C#/VB.NET/Csharp Writeline function
You can use .NET’s Composite Formatting to format the currency as shown below
- Double Incentive = 234.45;
- Console.WriteLine(“The agreed incentive in local currency is {0:C} ”, Incentive);
Double Incentive = 234.45;
Console.WriteLine("The agreed incentive in local currency is {0:C} ", Incentive);
If you want to convert it into dollars/pounds etc you need to change the culture info :
- Thread.CurrentThread.CurrentCulture = new CultureInfo(“en-US”, false);
- Console.WriteLine(“The agreed incentive in USD is {0:C} ”, Incentive);
- Thread.CurrentThread.CurrentCulture = new CultureInfo(“en-GB”, false);
- Console.WriteLine(“The agreed incentive in GBP is {0:C} ”, Incentive);
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", false);
Console.WriteLine("The agreed incentive in USD is {0:C} ", Incentive);
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB", false);
Console.WriteLine("The agreed incentive in GBP is {0:C} ", Incentive);
The above code needs the following directives
- using System.Threading;
- using System.Globalization;
using System.Threading; using System.Globalization;
Posted by Shasur at 12:37 AM
Labels: Format Currency to Pound/Euro using C#/VB.NET, Reset Currency using C#/VB.NET, VB.NET Format Currency to Pound/Euro/dollar
Advertisement




















