I have the following piece of code:
decimal kwh = decimal.Parse(textBox1.Text,
NumberStyles.AllowDecimalPoint,
NumberFormatInfo.CurrentInfo);
decimal sale_price = decimal.Parse(textBox2.Text,
NumberStyles.AllowDecimalPoint,
NumberFormatInfo.CurrentInfo);
decimal totalamnt = sale_price * kwh;
My problem is that when the Regional Settings are set to Greek, it doesnt accept any digits after the decimal point, When u enter it with " , "
I tried the InvariantInfo
in order to enter the decimals with " . " but again it doesnt accepts them.
The funny thing is that, when you go into Control Panel -> Region and Language -> Additional Settings you can set which operator you want for the decimal points and which for the thousands. If you set the decimal symbol to " . " ....... everything is working perfectly.
Whether you use InvariantInfo and enter it as " . " Or if you CurrentInfo and enter it as " , "
It is driving me crazy i tried many methods, not only the Parse method and the only way to get arround it is to set the decimal symbol to " . " but i cant just go around changing people's regional settings cause i might screw up other Greek software that they are using.
PLEASE people help me .. i am losing my mind with the GREEK language on computers. I would TRULY be GRATEFUL and THANKFUL to any one who can assist me to sort this out
(I set my regional setting to Greek)Insert statement i import 0.25 as sale_price and 5.26 as kwh. I am using a breakpoint and i see the values of the variables are 0.25 and 1.2 using InvariantInfo. When they are stored in the DB are stored as 0 and 5. When i set the decimal operator in the regional settings " . " instead of " , " i import 0.25 and 5.65 and they are stored correctly. When i set the Regional Settings to English Us and i insert 0.25 and 5.65 they are stored correctly