blog

Home / DeveloperSection / Blogs / C# Sort List Method

C# Sort List Method

Uttam Misra 5222 18-May-2012
This C# example shows how to sort elements in a List.
Sample Program that uses Sort [C#]

using System;
using System.Collections.Generic;
class Program
{
    static void Main()
    {
    List<string> list = new List<string>();
    list.Add("Dog");
    list.Add("BAT");
    list.Add("AGE");
    // Sort alphabetically, in ascending order (A - Z)
    list.Sort();
    foreach (string value in list)
    {
        Console.WriteLine(value);
    }
    }
}

Output

AGE
BAT
DOG

c# c# 
Updated 18-Sep-2014
More than 18 years of working experience in IT sector. We are here to serve you best.

Leave Comment

Comments

Liked By