Example セクションには、IGrouping<TKey,TElement>オブジェクトのキーと値の両方にアクセスする方法を示すコード例が含まれています。 IGrouping<TKey,TElement>型は、IGrouping<TKey,TElement>型の要素のシーケンスを返す、GroupBy標準クエリ演算子メソッドによって使用されます。
For example, it may involve translating the expression tree to a query language appropriate for an underlying data source.The IQueryable<T> interface enables queries to be polymorphic. That is, because a query against an IQueryable data source is represented as an expression tree, it can be ...
The following example creates aLookup<TKey,TElement>from a collection of objects. It then enumerates theLookup<TKey,TElement>and outputs each key and each value in the key's associated collection of values. It also demonstrates how to use the propertiesCountandItem[]and the methodsContainsand...
Queries are executedlazily, i.e. queries will only iterate their source as far as required. Consider the following (contrived) example: localnumber=from{3,2,1,0} :select(function(n)return1/nend) :first(function(n)returnn==1end)
For a significant chunk of software out in the wild, everything revolves around dealing with data from some source (Databases, JSON, XML, and so on). Often this involves learning a new API for each data source, which can be annoying. LINQ simplifies this by abstracting common elements of ...
The following code example demonstrates how to use Average(IEnumerable<Nullable<Int64>>) to calculate an average. C# Copy Run long?[] longs = { null, 10007L, 37L, 399846234235L }; double? average = longs.Average(); Console.WriteLine("The average is {0}.", average); // This code ...
Chunk<TSource>(IEnumerable<TSource>, Int32) Splits the elements of a sequence into chunks of size at mostsize. Concat<TSource>(IEnumerable<TSource>, IEnumerable<TSource>) Concatenates two sequences. Contains<TSource>(IEnumerable<TSource>, TSource) ...
Buffer poolsallow the use of heap memory without adding pressure to the garbage collector. It pre-allocates a chunk of memory and "rents" it as required. The garbage collector will add this memory to the Large Object Heap (LOH).
Chunk<TSource>(IEnumerable<TSource>, Int32) 将序列的元素拆分为大小块,最多size。 Concat<TSource>(IEnumerable<TSource>, IEnumerable<TSource>) 连接两个序列。 Contains<TSource>(IEnumerable<TSource>, TSource) 使用默认相等比较器确定序列是否包含指定的元素。
Chunk<TSource>(IEnumerable<TSource>, Int32) 将序列的元素拆分为大小块,最多size。 Concat<TSource>(IEnumerable<TSource>, IEnumerable<TSource>) 连接两个序列。 Contains<TSource>(IEnumerable<TSource>, TSource) 使用默认相等比较器确定序列是否包含指定的元素。