Possible Duplicate:
Difference between Convert.ToInt32(string) and Int32.Parse?
are these three exactly the same in performance? or whats the deal?
Possible Duplicate:
Difference between Convert.ToInt32(string) and Int32.Parse?
are these three exactly the same in performance? or whats the deal?
Convert.ToInt32 works against object
and accepts a range of data-types, of which `string is just one.
int.Parse is optimised for the very common string case, and raises an exception on failure. Useful when we expect an integer.
int.TryParse is like int.Parse, but no exception (false instead); useful for testing for an integer.
System.Convert check if the source object implements IConvertible and tehn call the proper method, so any object that "know" how to be converted to int can be converted that way. Parse and TryParse starts from the string reperesentation. Try parse returns a boolean signaling that conversion succeeded/failed. Parse trows if conversion fails.