可能重複:
Whats the main difference between int.Parse() and Convert.ToInt32更好地利用int.Parse或Convert.ToInt32
傢伙您好,我想知道什麼是PRO和使用 Convert.ToInt32 VS的利弊int.Parse。 感謝您的支持!
這裏我使用
int myPageSize = Convert.ToInt32(uxPageSizeUsersSelector.SelectedValue);
int myPageSize = int.Parse(uxPageSizeUsersSelector.SelectedValue);
我也發現了這篇文章語法的例子,也許可以幫助一個討論 http://dotnetperls.com/int-parse http://aspdotnethacker.blogspot.com/2010/04/difference-between-int32parsestring.html http://aspdotnethacker.blogspot.com/p/visual-studio-performance-wizard.html
這兩種方法都不如定製的int解析代碼,因爲解析中必須處理空格, - hyphones,new lines等。 – 2014-08-25 10:07:01