Convert.ToInt32(串)和Int32.Parse之间的区别? [英] Difference between Convert.ToInt32(string) and Int32.Parse?

查看:138
本文介绍了Convert.ToInt32(串)和Int32.Parse之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

精确复制:<一href="http://stackoverflow.com/questions/18465/net-parse-verses-convert">http://stackoverflow.com/questions/18465/net-parse-verses-convert 谁能帮助我?

Exact duplicate: http://stackoverflow.com/questions/18465/net-parse-verses-convert can anyone help me?

推荐答案

Convert.ToInt32(字符串) Int32.Parse(串)除非字符串实际上是一个空产生相同的结果。

Convert.ToInt32(string) and Int32.Parse(string) yield identical results except when the string is actually a null.

在这种情况下, Int32.Parse(空)抛出 ArgumentNullException

不过, Convert.ToInt32(空)返回零。

因此​​,最好是使用 Int32.Parse(字符串)

So it is better to use Int32.Parse(string)

这篇关于Convert.ToInt32(串)和Int32.Parse之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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