How to format currency in C#

1 Answer

0 votes
using System;
using System.Globalization;

public class Test
{
    public static void Main()
    {
        decimal price = 1319474.95M;

        Console.WriteLine(price.ToString("C2", new CultureInfo("en-US")));
        Console.WriteLine(price.ToString("C2", new CultureInfo("en-GB")));
    }
}




/*
run:

$1,319,474.95
£1,319,474.95

*/

 



answered Nov 18, 2021 by avibootz
...