Convert.ToInt32(串)和Int32.Parse之间的区别?区别、Convert、Parse

由网友(绕过山河错落)分享简介:精确复制:http://stackoverflow.com/questions/18465/net-parse-verses-convert谁能帮助我?Exact duplicate: 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)

阅读全文

相关推荐

最新文章