哪一个是处理和转换int.Parse()更快,int.TryParse(),Convert.Int32() [英] Which one is faster in processing and conversion int.Parse(), int.TryParse(), Convert.Int32()

查看:145
本文介绍了哪一个是处理和转换int.Parse()更快,int.TryParse(),Convert.Int32()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哪一个是速度快,功能强大,可靠。为什么?

  int.Parse()
int.TryParse()
Convert.ToInt32()
 

解决方案

转到阅读(性能剖析解析主场迎战的TryParse主场迎战的ConvertTo)的大部分add'l信息。

如果您不知道该字符串是解析的,那么 int.TryParse()会比任何其他人更快,捕获异常。

Which one is faster, powerfull and reliable. And why ?

int.Parse()
int.TryParse()
Convert.ToInt32()

解决方案

Go read this ("Performance Profiling Parse vs. TryParse vs. ConvertTo") for much add'l info.

If you are unsure if the string is parsable, then int.TryParse() will be MUCH faster than either of the others and catching the exceptions.

这篇关于哪一个是处理和转换int.Parse()更快,int.TryParse(),Convert.Int32()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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