The following code calls Sort method directly on the ArrayList instance.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class MainClass
{
public static void Main()
{
// Create a new ArrayList and populate it.
ArrayList arraylist = new ArrayList(4);
arraylist.Add("M");
arraylist.Add("K");
arraylist.Add("A");
arraylist.Add("A");
// Sort the ArrayList.
arraylist.Sort();
// Display the contents of the sorted ArrayList.
Console.WriteLine("\nArraylist sorted by content");
foreach (string s in arraylist)
{
Console.WriteLine(s);
}
}
}
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |