SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 159 | Next

Scott Klein

"Professional LINQ"

Skip(4)
SkipWhile
The SkipWhile operator skips or bypasses elements based on a specified predicate function, and continues
to bypass the elements as long as the specified condition is true (i.e., the condition is not met). The
remaining elements are then returned.
The following example skips all the values in the sequence that are less than 50 and returns the
remaining values.
Int[] randomNumbers = {86, 2, 77, 94, 100, 65, 5, 22, 70, 55, 81, 66, 45};
IEnumerable skipLessThan50 =
randomNumbers.OrderBy(num => num).SkipWhile(num =>
num < 50);
foreach (int number in skipLowerFour)
listbox1.Items.Add(number);
86
Chapter 4: LINQ Standard Query Operators
When this query is run, the following numbers are returned:
55
65
66
70
77
81
86
94
100
Likewise, this example could also be written using query syntax as follows:
IEnumerable skipLowerFour =
(from n in randomNumbers
order by n
select n).SkipWhile(num => num < 50);
Take
The Take operator returns contiguous elements within a sequence, starting at the beginning of the
sequence, up to the position specified.


Pages:
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6