SortedList is a part of System.Collection class. It works the same way Hashtable does. That is it takes KEY-VALUE pairs as input.
An advantage of SortedList is that it gives the output sorted by KEY values. For example
SortedList oSL = new SortedList(); oSL.Add("A", "1"); oSL.Add("C", "2"); oSL.Add("E", "3"); oSL.Add("B", "4"); oSL.Add("D", "5"); oSL.Add("F", "6");
IDictionaryEnumerator oIDic = oSL.GetEnumerator(); while (oIDic.MoveNext()) { Response.Write(oIDic.Value.ToString()); Response.Write(""); }
Output will be:
1 4 2 5 3 6
To remove a value from the list we use
oSL.Remove("D");
|
No responses found. Be the first to respond and make money from revenue sharing program.
|