Monday, October 27, 2014

get max and min of date from comma text file

You can do as follows:



int max, min;

public void ReadTextFile()
{
string[] lines = File.ReadAllLines(ofd.FileName);
List<int> list = new List<int>();

for (int i = 0; i < lines.Length; i++)
{
string[] words = lines[i].Split(',');
list.Add(int.Parse(words[1]));
}

max = list.Max();
min = list.Min();

}



Hope above help.

No comments:

Post a Comment