O'Reilly logo

Visual C#® 2012: How to Program, Fifth Edition by Harvey Deitel, Paul Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

9.5. Querying a Generic Collection Using LINQ

You can use LINQ to Objects to query Lists just as arrays. In Fig. 9.7, a List of strings is converted to uppercase and searched for those that begin with "R".

 1   // Fig. 9.7: LINQWithListCollection.cs  2   // LINQ to Objects using a List< string >.  3   using System;  4   using System.Linq;  5   using System.Collections.Generic;  6  7   public class LINQWithListCollection  8   {  9      public static void Main( string[] args ) 10      { 11         // populate a List of strings 12         List< string > items = new List< string >(); 13         items.Add( "aQua" ); // add "aQua" to the end of the List 14         items.Add( "RusT" ); // add "RusT" to the end of the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required