Art of BI: C# Convert Decimal to String
Christian Screen | | July 13, 2009

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 long 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.
Subscribe to Our Blog
Never miss a post! Stay up to date with the latest database, application and analytics tips and news. Delivered in a handy bi-weekly update straight to your inbox. You can unsubscribe at any time.
Popular Posts
Art of BI: BI Publisher (BIP) Quick Guide and Tips
Read our blog post on how to take over production support of BI Publisher reports.
How to Index a Fact Table – A Best Practice
At the base of any good BI project is a solid data warehouse or data mart.
Art of BI: How to Add Comments in Oracle BI (OBIEE)
Ultimately the goal of commentary in OBIEE is to have a system for persisting feedback, creating a call to action, and recognizing the prolific users.