开发者

ASP.NET Convert money datatype to displayable value on screen

开发者 https://www.devze.com 2023-03-24 00:54 出处:网络
Just pulled from database a value from DB with dat开发者_开发知识库atype and appearing on my screen as

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

ASP.NET Convert money datatype to displayable value on screen

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号