2011年9月21日
摘要: 1. string.Equals()string.Equals方法有很多的重载供我们使用,但是其中有些常常会被我们忽视掉。通常我们比较字符串会使用下面的方法public Order CreateOrder(string orderType, string product, int quantity, double price){ if (orderType.Equals("equity")) { } // ...}如果orderType为null会抛出NullReferenceException异常,所以为了不抛出异常,在判断之前先要进行null的判断,如下:if (o.. 阅读全文
posted @ 2011-09-21 17:48 BobLiu 阅读(243) 评论(0) 推荐(0) 编辑