The first thing to do is to add two new namespaces; so, enter the following after using System
:
using System.Linq; using System.Collections.Generic;
LINQ stands for Language Integrated Query, and using System.Collections .Generic
is for working with lists. These are the two new namespaces that we are using.
Next, in between the set of curly braces beneath the line beginning with protected void Button1_Click...
, the first thing that we will do is create an array of names. For this, enter the following:
IEnumerable<string> names = new string[] { "john", "job", "janet", "mary", "steve" };
Let's name it names
, and then say, create a new string
array. Then, to specify the initializer list, we enter a series of names in quotes, and close this with a semicolon.
Now notice that, on the left-hand side, we have IEnumerable
. This is a generic interface. As you can see, the new string
array in this line can be created this way because it...