Using Linq to Objects in C#

This tutorial was created with Microsoft Visual Studio .NET 2008. However, if you are using 2005, you can implement LINQ by downloading Microsoft's LINQ Community Technology Preview release from here.
In this tutorial, we will be looking at using LINQ to Objects. We will be creating a Windows Forms Application that will first define an array of numbers, and then we will use LINQ to Objects to interact with this collection of numbers. We will create buttons to display the results of calculations of the numbers, demonstrating the built-in functions of LINQ, that we can perform on most any collection.
We will start by designing our form with Four buttons and a label. The first button will be to display all the numbers in our array, which we will hard-code for this example. The label will be to show the results of our functions, and then the other three buttons we will use for LINQ functions.
We will also implement a StatusStrip control to make use of the label within, so that we can manipulate it on the mouse hover and leave events. The form may look something like this:

Once we are done with our form, we can double-click on the buttons in design view to create the click event handlers. We can also create the hover and leave handlers by clicking on the Events button in the Properties window, and then double-clicking on both of the MouseHover and MouseLeave events.
Let's start with the statusstrip label. We will change the text on hover and leave of each of the buttons to let the user know what each of the buttons does:
private void button1_MouseHover(object sender, EventArgs e)
{ toolStripStatusLabel1.Text = "Display all numbers in array"; }

private void button1_MouseLeave(object sender, EventArgs e)
{ toolStripStatusLabel1.Text = ""; }

private void button3_MouseHover(object sender, EventArgs e)
{ toolStripStatusLabel1.Text = "Get SUM of all numbers"; }

private void button3_MouseLeave(object sender, EventArgs e)
{ toolStripStatusLabel1.Text = ""; }

private void button2_MouseHover(object sender, EventArgs e)
{ toolStripStatusLabel1.Text = "Get numbers less than 10"; }

private void button2_MouseLeave(object sender, EventArgs e)
{ toolStripStatusLabel1.Text = ""; }

private void button4_MouseHover(object sender, EventArgs e)
{ toolStripStatusLabel1.Text = "Get average of numbers"; }

private void button4_MouseLeave(object sender, EventArgs e)
{ toolStripStatusLabel1.Text = ""; }
Next, we will create a method that will create an array of numbers that we can call from all of the buttons:
You can review the rest of the articlie at LinQhelp.com Happy coding!