Database Reference
In-Depth Information
Listing 18-1. LinqToObjects.cs
//Define string array
string[] names = { "Life is Beautiful",
"Arshika Agarwal",
"Seven Pounds",
"Rupali Agarwal",
"Pearl Solutions",
"Vamika Agarwal",
"Vidya Vrat Agarwal",
"Lionbridge Technologies"
};
//Linq query
IEnumerable<string> namesOfPeople = from name in names
where name.Length <= 16
select name;
foreach (var name in namesOfPeople)
{
txtDisplay.AppendText(name+"\n");
}
6. Run the program by pressing Ctrl+F5, and you should see the results shown in
Figure 18-4.
Figure 18-4. Retrieving names from a string array using LINQ to Objects
 
Search WWH ::




Custom Search