摘要:
List<Customer> customers = new List<Customer> { new Customer { Id = 1, Name="Dave", City="Sarasota" }, new Customer { Id = 2, Name="John", City="Tampa" }, new Customer { Id = 3, Name="Abe", City="Miami" } };而在2.0时代,我们为列表对象赋值要这样写 阅读全文
摘要:
为string类型,加一个扩展方法,IsNullOrEmpty,事实上.net已经把这个扩展方法集成了还可以设计一个过滤Email的扩展方法class Program{ static void Main(string[] args) { string newString = null; if (newString.IsNullOrEmpty()) { // Do Something } }}public static class Extensions{ public static bool IsNullOrEmpty(this string s) { return (s == null || 阅读全文