Format double to currency with currency format specifier "C" in CSharp

Description

The following code shows how to format double to currency with currency format specifier "C".

Example


using System;/* w w w . j av a  2  s. c  o  m*/
using System.Globalization;
public class MainClass {     
   static void Main()
   {
        double value = 12345.6789;
        Console.WriteLine(value.ToString("C", CultureInfo.CurrentCulture));
        
        Console.WriteLine(value.ToString("C3", CultureInfo.CurrentCulture));
        
        Console.WriteLine(value.ToString("C3", CultureInfo.CreateSpecificCulture("da-DK")));
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var