Query string array by its element length : Query « XML LINQ « C# / C Sharp






Query string array by its element length

 
using System;
using System.Linq;

class HelloWorld {
    static void Main() {
        string[] words = { "hello", "wonderful", "linq", "beautiful", "world" };
        var shortWords = from word in words
                         where word.Length <= 5
                         select word;

        foreach (var word in shortWords)
            Console.WriteLine(word);
    }
}

 








Related examples in the same category

1.A Simple XML Query Using LINQ to XML
2.Query XML document with where clause
3.Query XML document by attribute
4.Query XML with Descendants
5.Query XML document with Ancestors and First
6.Get Node by type with OfType
7.Query XML with namespace
8.Use Linq query to get XML document elements
9.use Linq to query an XML document