OrderByDescending (g => g).Take(2);
Both produce the same results; it is up to you to decide how you want to write the query.
Chapter 4 will discuss all of the standard query operators and provide examples using both query syntax
and method syntax where available.
44
Chapter 3: LINQ Queries
Using Query and Method Syntaxes
Here??™s a project that utilizes much of the information found in this chapter, such as query syntax and
method syntax, to create queries that will be used throughout the rest of this book. To start, you need a
place to create the applications used for this chapter.
In the root of your C drive, create a directory called Wrox. Underneath that directory, create another
directory called Chapter 3. Now, fire up Visual Studio 2008 and within the Recent Projects window of the
Start page, create a new project. This opens the New Project dialog.
In the New Project dialog, make sure that you have selected the correct Framework version (3.5) via the
far-left icon in the top-right corner, then select a Windows project type and set the project name to LINQ
with the path you just created (\Wrox\Chapter 3).
Pages:
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111