Steve,
Missed the 2nd parts of your question.
You can iterate over an ArrayList of strings "al" in the following ways:
// for loop
for (int i = 0;i < al.Length;i++) {
string s = (string)al[i];
// do stuff with s
}
// foreach loop
foreach (string s in al) {
// do stuff with s
}
// IEnumerator interface
IEnumerator alEnumerator = al.GetEnumerator();
while (alEnumerator.MoveNext()) {
string s = (string)alEnumerator.Current;
// do stuff with s
}
To obtain a count of occurences you'll have to write your own routine, along
the lines of:
int Occurs(string strSearch,ArrayList al) {
int intCount = 0;
foreach (string s in al) {
if (s == strSearch) {
intCount++;
}
}
return intCount;
}
--Bob
"steve smith" <bo**********@hotmail.com> wrote in message
news:4b**************************@posting.google.c om...
Hi I am new to this language, and still don't understand most of the
concepts, I am trying to sort an arraylist by alphabet, I belive i
need to use the IComparer interface, but have no idea how this works?
Does anyone have a sample of how i can sort my arraylist of words.
Also how is an arraylist iterated over and is it possible to obtain a
count of the number of occurences of each owrd in the array list? Many
thanks.