c# - int.Parse() 和 ConvertTo.Int32() 之间的区别?

标签 c# parsing

<分区>

Possible Duplicates:
difference between Convert.ToInt32 and (int)
Whats the main difference between int.Parse() and Convert.ToInt32

C#

type.Parse() 方法和 ConvertTo 类中的方法有什么区别吗?

最佳答案

不,Int32.ParseConvert.ToInt32(string) 之间没有实质性区别。后者只是将它的调用转发给 Int32.Parse

但有一个小区别是,如果您将 null 传递给 Convert.ToInt32,它将返回 0,而 Int32.Parse 将通过一个ArgumentNullException

关于c# - int.Parse() 和 ConvertTo.Int32() 之间的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5491040/

相关文章:

c# - 关闭窗体 C# 时单击 "yes"双?

java - 使用 Jackson 解析嵌套对象

c# - 使用有限状态机解析 CSV 数据

java - 使用 GSON 将 json 解析为由列表组成的 pojo

C 在数组中添加和搜索已解析的数据

java - 如何用java解析网页的特定部分?

c# - 从 WCF 创建的 ws-security header 中删除时间戳元素

c# - WPF 基于权限的授权

c# - 您应该在 ASP.NET MVC 的 global.asax 中使用 Application_Error 方法吗?

c# - C# 的 Antlr.Runtime 中缺少类