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

Related questions

1 answer 274 views
1 answer 214 views
214 views asked Apr 17, 2019 by avibootz
1 answer 163 views
3 answers 233 views
233 views asked Jan 5, 2023 by avibootz
1 answer 253 views
1 answer 265 views
2 answers 249 views
...