.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> LINQ >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Simple LINQ query on a Collection

Posted By:Sajid P K       Posted Date: October 18, 2010    Points: 15    Category: LINQ    URL: http://www.dotnetspark.com  

This code demonstrates use of LINQ query. This will retunes strings from a array of strings, which having its length greater than Five
 

static void Main(string[] args)  
    {  
      string []myNames = {"saji","sajid","sa","sajdipk"};             
      IEnumerable query = from name in myNames
                          where name.Length < 5
                          select name;    

     foreach(string n in query)          
          {
                Console.WriteLine(n);            
          } 
                Console.ReadLine();       
    }

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend