June 2008
Intermediate to advanced
784 pages
20h 36m
English
Here is a regular LINQ query expression. It uses the C# extensions discussed in the previous section. This query returns the list of multithreaded processes that have more than five active threads. For each multithreaded process, the process identifier and process name are returned:
var processes =
Process.GetProcesses()
.Where(p => p.Threads.Count > 5)
.Select(p => new { p.Id, Name = p.ProcessName });Figure 6-1 diagrams the preceding LINQ query expression. New features of C# 3.0 are mapped to various aspects of the query expression. The processes variable is an implicitly typed variable. The type is defined by the results of the query expression. The Where operator is an extension method. As with any extension method, the first ...
Read now
Unlock full access