Also, I need to sort this ArrayList. How can I do that?
myCode is below. It doesn't give the right Max value for example when I have like three numbers in my arraylist and all are negative. The max value is being returned is Zero.
ArrayList Values = new ArrayList();
double Max = 0; double Min =0; double temp = 0;
foreach (double x in Values)
{
temp = x;
if(Max
Max = temp;
}
if(Min > temp)
{
Min = temp;
}
}

Guest UserRank #259 · 9.8K reputationPosted Jul 9, 2014, 1:38 AM EDT
public static object GetMinValue(ArrayList arrList) { ArrayList sortArrayList = arrList; sortArrayList.Sort(); return sortArrayList[0]; } public static object GetMaxValue(ArrayList arrList) { ArrayList sortArrayList = arrList; sortArrayList.Sort(); sortArrayList.Reverse(); return sortArrayList[0]; }VulpesRank #55 · 29.2K reputationPosted Jul 9, 2014, 1:47 AM EDT
The output is: