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 265 views
1 answer 185 views
1 answer 127 views
127 views asked Oct 2, 2023 by avibootz
1 answer 181 views
181 views asked Nov 18, 2021 by avibootz
1 answer 241 views
1 answer 256 views
2 answers 242 views
...