In LINQ, Partition Operators are used for separating the given sequence into two portions without
Sorting the element and return the one of the portions
Method |
Description |
Take |
This operator is used fetch the first “n” number of elements from the data source where “n” is integer which is passed as a parameter to the Take method. |
TakeWhile |
This operator behaves similarly to the take() method except that instead of taking the first “n” element of sequence , It takes all of initial elements of sequence that meet the criteria specified by the predicate, and stops on the first element that doesn’t meet the criteria |
Example: Take() Method – C# |
IList
var
foreach
|
Output - |
One Two |
Example: TakeWhile() Method –
C# |
IList
var
foreach
|
Output - |
Three |
No comments:
Post a Comment