string array sorted by the length each element

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass {
    public static void Main() {

        string[] words = { "abc", "bcd", "def" };

        var sortedWords =
            from w in words
            orderby w.Length
            select w;

        Console.WriteLine("The sorted list of words (by length):");
        foreach (var w in sortedWords) {


This entry was posted in LINQ. Bookmark the permalink.