TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Eline Sami
NA
47
70.8k
Get MAX and MIN Values in ArrayList
Jul 9 2014 5:17 AM
I have an ArrayList that contains some double values and I need to get the MAX and MIN values.
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<temp)
{
Max = temp;
}
if(Min > temp)
{
Min = temp;
}
}
Reply
Answers (
2
)
When to use string and when Stringbuilder in .NET?
How to check completion of thread