Click here to Skip to main content
15,920,613 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have code which is incorrect on the server but not locally!


C#
//Exchange rate conversion
  conversion = Convert.ToDecimal(p.TotalPrice,CultureInfo.InvariantCulture) * _currency.GetExchangeRate(curFrom, curTo);

//the tostring conversion
conversion.ToString("#,#",CultureInfo.InvariantCulture) 


THE BUG
on the live server it adds three extra zeros at the end but on local server it does not

Facepalm!!!!
Posted
Updated 1-Dec-15 23:52pm
v2
Comments
[no name] 2-Dec-15 6:20am    
I suspect this is due to culture info only. In your local culture is SA but your is at UK then it will give different result. But here you are using invariant culture so it should work fine.
Member 10146034 2-Dec-15 6:28am    
thx for the reply , aint CultureInfo.InvariantCulture suppose to help with this?

Yes, it is due to culture info only. You can use
C#
string.Format("{0:00}",conversation);
that convert your decimal value to point 2 place decimal value.
 
Share this answer
 
I changed culture on IIS on server , it works now thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900