字符串转换为Int [英] String Conversion to Int

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

问题描述

这是一个新手问题。如果我在错误的地方,请告诉我。


我使用外部应用程序返回两个字符串,我需要将b $ b分开。< br $>
val1 =" $ 100,000"

val2 =" $ 45"


我知道我不能划分数字,因为它们都是字符串。所以我

删除了$和,。然后我明确地转换了它们,

System.Convert.ToInt32(val)。


然而这会导致错误。有什么东西我不见了吗?


感谢您的帮助。

This is a newbie question. Let me know if I''m in the wrong place.

I working with an external application that returns two strings that I
need to divide.
val1 = "$100,000"
val2 = "$45"

I know I can''t divide the numbers because they are both strings. So I
removed the "$" and the ",". Then I explicitly converted them,
System.Convert.ToInt32(val).

However this causes an error. Is there something that I am missing?

Thanks for the help.

推荐答案

100,000"

val2 ="
100,000"
val2 = "


45"


我知道我不能分数因为它们都是字符串。所以我

删除了
45"

I know I can''t divide the numbers because they are both strings. So I
removed the "


"和,。然后我明确地转换了它们,

System.Convert.ToInt32(val)。


然而这会导致错误。有什么东西我不见了吗?


感谢您的帮助。

" and the ",". Then I explicitly converted them,
System.Convert.ToInt32(val).

However this causes an error. Is there something that I am missing?

Thanks for the help.


这篇关于字符串转换为Int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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