ASP.NET Convert money datatype to displayable value on screen
Just pulled from database a value from DB with dat开发者_开发知识库atype and appearing on my screen as
9.8600
Whats best way to get this to get to
€9.86
Pass it to ToString with a c
you can optionally add an integer after the letter c for the precision. If I wanted 2 digits after the decimal "c2"
valueFromDB.ToString("c")
For C#:
decimal value = 123.456m;
Console.WriteLine("Your account balance is {0:C2}.", value);
// Displays "Your account balance is $123.46."
For VB:
Dim value As Decimal = 123.456d
Console.WriteLine("Your account balance is {0:C2}.", value)
' Displays "Your account balance is $123.46."
If in doubt, MSDN : http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx
精彩评论