输入字符串格式错误 [英] input string in wrong format

查看:76
本文介绍了输入字符串格式错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



我收到的错误输入字符串格式不正确。

Hi All

I am getting the error input string not in correct format.

Tusd = decimal.Parse(drTExp.GetValue(0).ToString());



请有人帮帮我。



谢谢





问候



Suman


Please can someone help me.

Thanks


Regards

Suman

推荐答案

Tusd = decimal.Parse(drTExp.GetValue(0).ToString());





这里你收到此错误,因为当编译器尝试将drTExp.GetValue(0).ToString()转换为十进制时,它会得到错误的字符串格式。

当你的字符串为空或空或不包含任何小数值时会发生这种情况。



在这里你可以通过检查字符串来避免这种情况在你进行对话之前。并使用Convert.ToString()而不是.ToString()





Here You are getting this error because when compiler try to convert drTExp.GetValue(0).ToString() to decimal its getting wrong string format.
This happens when your string is empty or null or its not containing any decimal value.

Here you can avoid this by checking for the string before you do the conversation.And use Convert.ToString() instead of .ToString()

Tusd =  !string.IsNullOrEmpty(Convert.ToString(drTExp.GetValue(0))) 
        ? 
        decimal.Parse(Convert.ToString(drTExp.GetValue(0))) 
        :
        0;


这篇关于输入字符串格式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆