摘要:
string sourceString = "int i = 5; string s = (i % 2 == 0 ? \"偶数\" : \"奇数\");"; //查询所有的数字、标点、符号 var query = from item in sourceString where char.IsDigit(item) || char.IsSymbol(item) || char.IsPunctuation(item) select item; //显示查询结果 fo... 阅读全文
摘要:
SortedDictionary<int, UserInfo> users = new SortedDictionary<int, UserInfo>(); //为泛型排序字典添加3个元素,注意键是按照3、2、1的顺序添加 users.Add(3, new UserInfo(1, "User01", "01")); users.Add(2, new UserInfo(2, "User02", "02")); users.Add(1, new UserInfo(3, "User03& 阅读全文
摘要:
List<Store> StoreList = new List<Store> { new Store { WareHouse="一号仓库", Product="电视机", Quantity=10 }, new Store { WareHouse="一号仓库", Product="电视机", Quantity=20 }, new Store { WareHouse="一号仓库", Product="洗衣机", Quantity=30 }, new St 阅读全文
摘要:
//构建泛型哈希集 HashSet<UserInfo> users = new HashSet<UserInfo>(); for (int i = 0; i < 10; i++) { users.Add(new UserInfo(i % 2, "User0" + i.ToString(), "0" + i.ToString())); } //LINQ对泛型哈希集进行排序操作 var query = from item in users orderby item.UserCo... 阅读全文