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 160 | Next

Scott Klein

"Professional LINQ"


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 takeTopFour =
randomNumbers.OrderByDescending(num => num).Take(4);
foreach (int number in takeTopFour)
listbox1.Items.Add(number);
When this query is run, the following numbers are returned:
100
94
86
81
This example could also be written using query syntax as follows:
IEnumerable takeTopFour =
(from n in randomNumbers
order by n descending
select n).Take(4);
TakeWhile
The TakeWhile operator returns elements based on a specified predicate function, and continues to take
the elements as long as the specified condition is true (i.e., the condition is not met). The remaining
elements are skipped.
87
Part I: Introduction to Project LINQ
The following example takes all the values in the sequence that are less than 50 and skips the
remaining values.
Int[] randomNumbers = {86, 2, 77, 94, 100, 65, 5, 22, 70, 55, 81, 66, 45};
IEnumerable takeGreaterThan50 =
randomNumbers.


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