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
csharp beginner
NA
38
11.9k
find max value
Oct 30 2013 7:25 AM
i need to find max value within a file. This means finding max value within each 1000 values in a file, i.e., if there is 5000 values within a file then there should be 5 max values. Within first 1000 values: one max value, then within next 1000 values one more max value.... and so on.
# the size of the file will be unknown
# i had prepared a code for finding max value within first 1000 values in the file. I was thinking of iterating it, to get the desired results, but could not. The codes are as follows.
List<Double> list = new List<Double>();
StreamReader dat = new StreamReader(file path);
//int count = 1;
string dataline = "";
for (int i = 1; i <= dat.BaseStream.Length; i+=1000)
{
while ((dataline = dat.ReadLine()) != null)
{
Double sdat = Double.Parse(dataline);
list.Add(sdat);
richTextBox1.Text = list.Take(1000).Max().ToString();
}
}
please help!
Thank you.
Reply
Answers (
4
)
Get user Name and Photograph from Twitter in Windows 8 App
Requested registry access is not allowed