
Hi,
Let us consider an ArrayList called arrScores.
ArrayList arrScores = new ArrayList();
Am adding few numeric items into ArrayList like
arrScores.Add(5);
arrScores.Add(3);
arrScores.Add(7);
arrScores.Add(1);
arrScores.Add(2);
arrScores.Add(4);
arrScores.Add(6);
Now Am having order of the items like 5,3,7,1,2,4,6.
Now call the Sort Method.
arrScores.Sort(); // The array list items will be sorted in ascending order like 1,2,3,4,5,6,7
Now call the Reverse method.
arrScores.Reverse(); // The array list items will be reversed like 7,6,5,4,3,2,1
Now get the highest value by giving 0 index in the array list.
int nHighestVal = int.Parse(arrScores[0].ToString()); // The nHighestVal will be 7.
If you want the least value. Do only sort and get the item by 0th index.
Nav234, if this helps please login to Mark As Answer. | Alert Moderator