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

Scott Klein

"Professional LINQ"


ArrayList names = new ArrayList();
names.Add("Alex");
names.Add("Chuck");
names.Add("Dave");
names.Add("Dinesh");
names.Add("Joe");
names.Add("John");
names.Add("Sarah");
74
Chapter 4: LINQ Standard Query Operators
names.Add("Steve");
IEnumerable query = names.Cast().Select(name => name);
foreach (string item in query)
listBox1.Items.Add(item);
OfType
The OfType operator enables you to filter elements of an IEnumerable object based on a specific type. In
the following example, the OfType operator returns only those elements in the sequence that can be cast
to a type of int:
ArrayList names = new ArrayList(7);
names.Add("Scott");
names.Add(1);
names.Add("Dave");
names.Add(2);
names.Add("Dave");
names.Add(3);
names.Add("Steve");
names.Add(4);
names.Add("Joe");
IEnumerable query = names.OfType();
foreach (int item in query)
listBox1.Items.Add(item);
Here are the query??™s results:
1
2
3
4
By using the OfType operator on an IEnumerable object, you have the capability to apply and use standard
query operators to query the sequence.


Pages:
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6