建议4.TryParse比Parse好 如果注意观察,除string之外的所有的基元类型.会发现它们都有两个将字符串转换为自身类型的方法:Parse和TryParse.以类型double为例. 两者最大的区别是,如果字符串格式不满足转换的要求,Parse方法将会引发一个异常:TryParse方法则不会引发异常,它会返回false,同时将result置为0. //Parse int a = int.Parse("123a"); //TryParse int x = 0; if (int.…
先看HashMap的定义: public class HashMap<K,V>extends AbstractMap<K,V>implements Map<K,V>, Cloneable, Serializable HashMap是AbstractMap的子类,实现了Map接口. HashMap() Constructs an empty HashMap with the default initial capacity (16) and the default loa…