Query string array by its element length

image_pdfimage_print

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); } } [/csharp]

This entry was posted in XML LINQ. Bookmark the permalink.