How to convert decimal to string in currency format with C#

1 Answer

0 votes
using System;
using System.Globalization;
					
public class Program
{
	public static void Main()
	{
		decimal d = 28983409.9847m;
		
		string specifier;
		CultureInfo culture;

		specifier = "C";
		culture = CultureInfo.CreateSpecificCulture("en-US");
		Console.WriteLine(d.ToString(specifier, culture));
		
		culture = CultureInfo.CreateSpecificCulture("en-GB");
		Console.WriteLine(d.ToString(specifier, culture));
	}
}



/*
run:

$28,983,409.98
£28,983,409.98

*/

 



answered Feb 2, 2021 by avibootz

Related questions

1 answer 254 views
1 answer 180 views
1 answer 125 views
125 views asked Oct 2, 2023 by avibootz
1 answer 172 views
172 views asked Nov 18, 2021 by avibootz
1 answer 230 views
1 answer 244 views
2 answers 235 views
...