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 274 views
1 answer 194 views
1 answer 132 views
132 views asked Oct 2, 2023 by avibootz
1 answer 187 views
187 views asked Nov 18, 2021 by avibootz
1 answer 188 views
1 answer 137 views
1 answer 160 views
...