The ArtOfBI.com Newsletter

Is stupid new and freshly informative on BI and EPM.

Save one little gremlin by not pouring water on its head.

Or, sign up for killer tips, tricks and other BI / EPM goodness delivered right to your inbox.

Hell just do both. Enter your email below.

Oh no what happened?
I already signed up.

BTW, Signing up gets rid of this annoying banner.

Cheers,
Christian & The ArtOfBi.com Team

Tag Archive | "conversion"

Tags: c#, conversion

C# Convert Decimal to String


Microsoft usually has good documentation but on this particular topic I always felt that it was lacking. Here is the MS core documentation for converting a decimal to a string, http://msdn.microsoft.com/en-us/library/59095yyw.aspx.

I recently needed to ensure that I was only getting only two decimal places on a dollar amount as I converted it into a string and was going to write a nice lengthy post myself and then I found this really nice post over at csharp-examples (view post).

Mainly I was looking for the following syntax just to ensure that I was setting up things correctly:

// just two decimal places
String.Format("{0:0.00}", 123.4567);      // "123.46"
String.Format("{0:0.00}", 123.4);         // "123.40"
String.Format("{0:0.00}", 123.0);         // "123.00"

They have some other great custom formatting items as well. Check ‘em out.

Posted in C#.NETComments (0)

My name is Christian Screen, a Business Intelligence mastermind working with mainly Oracle and Microsoft technologies. The views expressed here are my own and do not reflect the views of Oracle, Microsoft, or my employer. RSS