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.