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 254 views
1 answer 205 views
205 views asked Apr 17, 2019 by avibootz
1 answer 155 views
3 answers 218 views
218 views asked Jan 5, 2023 by avibootz
1 answer 230 views
1 answer 244 views
2 answers 235 views
...