Int. Trypasre (), int. pasre (), Convert. To32 (), sqlconvertint

Source: Internet
Author: User

Int. Trypasre (), int. pasre (), Convert. To32 (), sqlconvertint

Int. Trypasre ()

Int32.TryParse (source, result) does not throw an exception in any case. Only true or false is returned to indicate whether the parsing is successful. If the parsing fails, the caller will get a value of 0.

Int. pasre ()

If the parsing fails, Int32.Parse (source) will always throw an exception.

Convert. To32 ()

Convert. ToInt32 (source) does not throw an exception when source is null, but simply returns 0 to the caller.

 

Essential differences between Pasre and Convert

Convert is used to Convert the types inherited from the object type (of course, all types are inherited from the object), but generally Convert is used to Convert directly to the obejct type.

Parse is only used to convert data of the String type.

 

Performance:

Whether it is Pasre or Convert, the underlying layer calls the Pasre () callback of the Int class to only read the class Number for type conversion. Therefore, Pasre is faster than Convert.

 

PS: Here is a summary of parse and Convert,

Most of them are from http://bbs.csdn.net/topics/280063811.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.