I am working with workflows in Sharepoint 2007. In the Workflow I am accessing a Inforpath form the Code Behind and add some Recurring values to a Sharepoint List.
string strProfitMargin = ProfitMargin;
decimal margin1 = decimal.Parse(strProfitMargin);
listItem["Test9"] = Math.Round(margin1, 2).ToString();
Suppose for the ProfitMargin I get a value "0.4230769230769231"
.
Decimal.Parse
Method Returns 4230769230769231
without the Decimal point. Ultimately Math.Round also not working. This works perfectly in my machine. But in QA servers Its not Working. Please Help me and Explain why the decimal.Parse method not Working? Same Way for double.Parse() is returning a value without a decimal.
Thanks in Advance!
My strong suspicion is that you're running on a machine with a culture which doesn't use .
as a decimal point.
Specify the culture explicitly, e.g. to the invariant culture
decimal margin1 = decimal.Parse(strProfitMargin, CultureInfo.InvariantCulture);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With