How to Sort a StringCollection object


If you want to sort a StringCollection object you have to use following trick as there is no built in method in StringCollection class for sorting.

StringCollection sc = new StringCollection();

sc.Add("Nokia");
sc.Add("Sony");
sc.Add("HP");
sc.Add("Dell");
sc.Add("IBM");

ArrayList.Adapter(sc).Sort();

 

 

About author


User avatar

Waqas Anwar

Founder of EzzyLearning.com, Senior Consultant, Microsoft .NET and Web Technologies

Add Comment