linq to object的常用方法收藏
http://www.hookedonlinq.com/ 是个学习LINQ的不错的网站
主要的操作方法
Operator Type | Operator | Description |
---|---|---|
Aggregation | Aggregate | The Aggregate operator applies a function over a sequence. |
Average | The Average operator computes the average of a sequence of numeric values. | |
Count | The Count operator counts the number of elements in a sequence with a return type of int. | |
LongCount | The LongCount operator counts the number of elements in a sequence with a return type of Long. | |
Max | The Max operator finds the maximum of a sequence of numeric values. | |
Min | The Min operator finds the minimum of a sequence of numeric values. | |
Sum | The Sum operator computes the sum of a sequence of numeric values. | |
Concatenation | Concat | The Concat operator concatenates two sequences. |
Conversion | Cast | The Cast operator casts the elements of a sequence to a given type. |
OfType | The OfType operator filters the elements of a sequence based on a type. | |
ToArray | The ToArray operator creates an array from a sequence. | |
ToDictionary | The ToDictionary operator creates a Dictionary | |
ToList | The ToList operator creates a List | |
ToLookup | The ToLookup operator creates a Lookup | |
ToSequence | The ToSequence operator returns its argument typed as IEnumerable | |
Element | DefaultIfEmpty | The DefaultIfEmpty operator supplies a default element for an empty sequence. |
ElementAt | The ElementAt operator returns the element at a given index in a sequence. | |
ElementAtOrDefault | The ElementAtOrDefault operator returns the element at a given index in a sequence, or a default value if the index is out of range. | |
First | The First operator returns the first element of a sequence. | |
FirstOrDefault | The FirstOrDefault operator returns the first element of a sequence, or a default value if no element is found. | |
Last | The Last operator returns the last element of a sequence. | |
LastOrDefault | The LastOrDefault operator returns the last element of a sequence, or a default value if no element is found. | |
Single | The Single operator returns the single element of a sequence. | |
SingleOrDefault | The SingleOrDefault operator returns the single element of a sequence, or a default value if no element is found. | |
Equality | SequenceEqual | The SequenceEqual operator checks whether two sequences are equal. |
Generation | Empty | The Empty operator returns an empty sequence of a given type. |
Range | The Range operator generates a sequence of integral numbers. | |
Repeat | The Repeat operator generates a sequence by repeating a value a given number of times. | |
Grouping | GroupBy | The GroupBy operator groups the elements of a sequence. |
Joining | GroupJoin | The GroupJoin operator performs a grouped join of two sequences based on matching keys extracted from the elements. |
Join | The Join operator performs an inner join of two sequences based on matching keys extracted from the elements. | |
Ordering | OrderBy | The OrderBy operator orders a sequence according to one or more keys in ascending order. |
ThenBy | The ThenBy operator orders an ordered sequence according to one or more keys in ascending order. | |
OrderByDescending | The OrderBy operator orders a sequence according to one or more keys in descending order. | |
ThenByDescending | The ThenBy operator orders an ordered sequence according to one or more keys in descending order. | |
Reverse | The Reverse operator reverses the elements of a sequence. | |
Partitioning | Skip | The Skip operator skips a given number of elements from a sequence and then yields the remainder of the sequence. |
SkipWhile | The SkipWhile operator skips elements from a sequence while a test is true and then yields the remainder of the sequence. | |
Take | The Take operator yields a given number of elements from a sequence and then skips the remainder of the sequence. | |
TakeWhile | The TakeWhile operator yields elements from a sequence while a test is true and then skips the remainder of the sequence. | |
Quantifiers | All | The All operator checks whether all elements of a sequence satisfy a condition. |
Any | The Any operator checks whether any element of a sequence satisfies a condition. | |
Contains | The Contains operator checks whether a sequence contains a given element. | |
Restriction | Where | The Where operator filters a sequence based on a predicate. |
Projection | Select | The Select operator performs a projection over a sequence. |
SelectMany | The SelectMany operator performs a one to many element projection over a sequence. | |
Set | Distinct | The Distinct operator eliminates duplicate elements from a sequence. |
Except | The Except operator produces the set difference between two sequences. | |
Intersect | The Intersect operator produces the set intersection of two sequences. | |
Union | The Union operator produces the set union of two sequences. |