摘要:
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.. 阅读全文