foreach (var item in quary.ToList()) { //取值item } 回到顶部 Where条件筛选。 //将provice=吉林的筛选出来。 list = list.Where(x => x.provice == "吉林").ToList(); //将包含1,5条件的数据筛选出来,相当于sql里的in用法:select * from 表 where user_type in (1,5) list= list.Where...
) Console.ReadKey() End Sub Shared Sub OutputQueryResults(ByVal query As IEnumerable(Of String), ByVal message As String) Console.WriteLine(System.Environment.NewLine & message) For Each item As String In query Console.WriteLine(item) Next Console.WriteLine(query.Count...
{ "Banana", 2 }, { "Orange", 3 }, { "Grapes", 4 } }; List<int> excludedValues = new List<int>() { 2, 3, 5 }; var query = dictionary.Where(item => !excludedValues.Contains(item.Value)); foreach (var item in query) { Console.WriteLine(item.Key + ": " + item.Value...
' Merge the data by using an anonymous type.' Note the dynamic creation of a list of integers for the' ExamScores member. We skip 1 because the first string' in the array is the student ID, not an exam score.DimqueryNamesScores2 =FromnameLineInn...
};varpTemp=frompinpersonList2selectnew{p.Name, AgeScope=p.Age>20?"Old":"Young"};foreach(variteminpTemp) { Console.WriteLine(string.Format("{0}:{1}",item.Name,item.AgeScope)); } 5.使用泛型集合代替非泛型集合# 注意,非泛型集合在System.Collections命名空间下,对应的泛型集合则在System.Collec...
Each ChunkItem // has a reference to the next ChunkItem in the list. class ChunkItem { public ChunkItem(TSource value) => Value = value; public readonly TSource Value; public ChunkItem? Next; } public TKey Key { get; } // Stores a reference to the enumerator f...
Each ChunkItem // has a reference to the next ChunkItem in the list. class ChunkItem { public ChunkItem(TSource value) => Value = value; public readonly TSource Value; public ChunkItem? Next; } public TKey Key { get; } // Stores a reference to the enumerator for the source ...
Next' Group files according to their size,' leaving out the ones under 200KDimsizeGroups =FromfileAsSystem.IO.FileInfoInfileList _Wherefile.Length >0_LetgroupLength = file.Length /100000_GroupfileBygroupLengthIntofileGroup =Group_WheregroupLength >=2_Order...
' Returns a list of cities with no duplicate entries.Dimcities =FromitemIncustomersSelectitem.CityDistinct Skip 子句 選擇性。Skip子句略過集合中指定數目的元素,然後傳回其餘元素。 例如: VB ' Returns a list of customers. The first 10 customers' are ignored and the remaining customers are' returned...
list.Add(new Employee { Id = 5, Name = "田七", Age = 33, Gender = true, Salary = 3000}); IEnumerable<Employee> items = list.Where(e => e.Age > 40); foreach (var item in items) { Console.WriteLine(item); } } class Employee ...