TodorMitev

sortStrings

Dec 27th, 2011
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace _05SortStringArray
  7. {
  8.     class SortStringArray
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             List<string> input = new List<string>();
  13.             while (input.Count < 5)
  14.             {
  15.                 input.Add(Console.ReadLine());
  16.             }
  17.             var result = from elem in input
  18.                          orderby elem.Length ascending
  19.                          select elem;
  20.  
  21.             Console.WriteLine(new String('-', 30));
  22.             foreach (var item in result)
  23.             {
  24.                 Console.WriteLine(item);
  25.             }
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment