Convert.ToInt32 的定义如下: public static int ToInt32(字符串值){如果(值==空)返回0;返回Int32.Parse(value,CultureInfo.CurrentCulture);} intID1 = Int32.Parse(myValue.ToString());intID2 = Convert.ToInt32(myValue);Which one is better and why? 解决方案 They are exactly the same, except that Convert.ToInt32(null) returns 0.Convert.ToInt32 is defined as follows: public static int ToInt32(String value) { if (value == null) return 0; return Int32.Parse(value, CultureInfo.CurrentCulture); } 这篇关于Int32.Parse()VS Convert.ToInt32()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-15 18:05