Custom collection class sorting (sort ()) method essays
Many custom collection classes are defined in the ASP.net startkit timetracker
For example:
Userscollection
Timeentriescollection
Wait a minute
They're all subclasses of the ArrayList class.
For example:
Timeentriescollection Store Custom Class Timeentry
These custom collection classes implement sorting method sort
Let's look at a piece of code I wrote:
Using System;
Using System.Collections;
Namespace Arraylistsort
{
class Class1
{
[STAThread]
static void Main (string[] args)
{
ArrayList a=new ArrayList (8);
A.add (a);
A.add (2);
A.sort ();
IEnumerator Ienumerator=a.getenumerator ();
while (Ienumerator.movenext ())
{
Console.WriteLine (iEnumerator.Current.ToString ());
ArrayList b=new ArrayList (8);
B.add (New Class2 ("Wo"));
B.add (New Class2 ("AI"));
B.add (New Class2 ("I"));
B.sort ();
IEnumerator Iienumerator=b.getenumerator ();
while (Iienumerator.movenext ())
{
Console.WriteLine ((Class2) iienumerator.current). A);
}
Console.ReadLine ();
}
public
class Class2
{public
class2 (string str)
{
this.a=str;
}
string A;
public string a
{
get
{
A;
}}}