Database Reference
In-Depth Information
Try It: Coding a Simple LINQ to Objects Query
In this exercise, you'll create a Windows Forms application that has one TextBox. The application will
retrieve and display some names from an array of strings in a TextBox control by using Linq to Objects.
1. Right-click Form1.cs in the Chapter18 solution, select the Rename option, and
rename the form to LinqToObjects.
2. Select the LinqToObjects form by clicking the form's title bar, and set the Size
property's Width to 308 and Height to 311.
3. Drag a TextBox control onto the form, and position it toward the center of the
form. Select this TextBox, navigate to the Properties window, and set the
following properties:
Set the Name property to txtDisplay.
For the Size property, set Width to 244 and Height to 216.
Set the Multiline property to True.
4. Now your LinqToObjects form in the Design view should look like Figure 18-3.
Figure 18-3. The Design view of the LinqToObjects form
5. Double-click the empty surface of the LinqToObjects.cs form, and it will open
the code editior window, showing the LinqToObject_Load event. Place the
code in Listing 18-1 in the LinqToObjects_Load event.
 
Search WWH ::




Custom Search