If you run this code:
decimal d1 = 0m;
decimal d2 = 0.0m;
decimal d3 = 0.0000m;
string str1 = d1.ToString(System.Globalization.CultureInfo.InvariantCulture);
string str2 = d2.ToString(System.Globalization.CultureInfo.InvariantCulture);
string str3 = d3.ToString(System.Globalization.CultureInfo.InvariantCulture);
You get :
str1: "0",
str2: "0.0",
str3: "0.0000"
Is there some way in code to get the number of decimal places (as would be output by decimal.ToString above) in the decimal variables ?
i.e. want to get:
d1: 0
d2: 1
d3: 4
(In case anyone is wondering why this is required, it is for some workaround code for a problem involving SSRS and Excel: http://social.technet.microsoft.com/Forums/sqlserver/en-US/5c4fc104-5d69-409d-9a6e-a6354922729a/exporting-ssrs-report-to-excel-2007-excel-found-unreadable-content-in-file-xlsx)
EDIT:
Title has been changed. Sorry for the confusion, guys. In the underlying problem I'm trying to solve, the decimals are always 0 - hence the confusion.