Users Pricing

blog

home / developersection / blogs / c# sort list method

C# Sort List Method

Uttam Misra 5735 18 May 2012 Updated 18 Sep 2014
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

Uttam Misra

Information Technology

More than 18 years of working experience in IT sector. We are here to serve you best.