摘要: 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... 阅读全文
posted @ 2013-01-19 12:00 yellowshorts 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 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& 阅读全文
posted @ 2013-01-19 11:49 yellowshorts 阅读(1335) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2013-01-19 11:48 yellowshorts 阅读(161) 评论(0) 推荐(0) 编辑
摘要: //构建泛型哈希集 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... 阅读全文
posted @ 2013-01-19 11:23 yellowshorts 阅读(128) 评论(0) 推荐(0) 编辑
摘要: DataClassesDataContext dc = new DataClassesDataContext(); var query = from type in dc.DictionaryType select new { DictTypeName = type.DictTypeName, ItemList = from item in dc.DictionaryItem where item... 阅读全文
posted @ 2013-01-18 16:57 yellowshorts 阅读(102) 评论(0) 推荐(0) 编辑
摘要: int[] arr1 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };//构造整型数组arr1 int[] arr2 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };//构造整型数组arr2 int[] arr3 = { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };//构造整型数组arr3 //判断arr1和arr2是否相等 bool isEqual = arr1.SequenceEqual(arr2); Response.Write("arr1和arr2是否相等... 阅读全文
posted @ 2013-01-18 16:53 yellowshorts 阅读(1210) 评论(0) 推荐(0) 编辑
摘要: //构造数组序列 int[] arr = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; var query1 = arr.Skip(8);//跳过8个元素取值 Response.Write("arr.Skip(8):<br/>");//结果等于8,9 foreach (var item in query1) { Response.Write(item + " , "); } Response.Write("<br/>"); var query2 = arr.SkipWhile(itm =. 阅读全文
posted @ 2013-01-18 16:51 yellowshorts 阅读(109) 评论(0) 推荐(0) 编辑
摘要: //构造序列 List<UserInfo> users = new List<UserInfo> { new UserInfo{UserCode=1, UserName="User001", Password="001"}, new UserInfo{UserCode=2, UserName="User002", Password="002"}, new UserInfo{UserCode=3, UserName="User003", Password="003 阅读全文
posted @ 2013-01-18 16:50 yellowshorts 阅读(122) 评论(0) 推荐(0) 编辑
摘要: //查询并返回重复序列 var query = Enumerable.Repeat<int>(9, 4); //显示查询结果 foreach (var item in query) { Response.Write(item.ToString() + " , ");//结果等于9 , 9 , 9 , 9 , } 阅读全文
posted @ 2013-01-18 16:48 yellowshorts 阅读(147) 评论(0) 推荐(0) 编辑
摘要: //查询并返回11至20范围内的数字序列 var query = Enumerable.Range(11, 10); //显示查询结果 foreach (var item in query) { Response.Write(item.ToString() + " , "); } 阅读全文
posted @ 2013-01-18 16:35 yellowshorts 阅读(107) 评论(0) 推荐(0) 编辑