System.FormatException : Input string was not in a correct format ,on converting string to decimal.

北战南征 提交于 2019-11-30 20:24:54
sn1ckers

Try using "0,85" instead of "0.85". I think you can use the dot decimal if you change culture. Here is some more information: How to change symbol for decimal point in double.ToString()?

Please try with the below code snippet.

CultureInfo info = CultureInfo.GetCultureInfo("es-ES");
string storedValue = "3,85";
decimal oldAmount;
bool succes = Decimal.TryParse(storedValue, NumberStyles.Any, info, out oldAmount);

Use TextBox.Text instead:

bool succes = Decimal.TryParse(TextBox.Text, out oldAmount);

TextBox.value is wrong. YourTextBox.Text is correct...!

bool success = Decimal.TryParse(TextBox.Text, out oldAmount);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!