title: Maximum value in datatable column c#
body: <p>I have a set of text files that I am reading into a datatable. I want to be able to read the frist column (Id) and find out the highest number. Each of the files goes from 0 to at least 21 sequentially. I tried suggestions from the following link: <a href="https://stackoverflow.com/questions/2442525/how-to-select-min-and-max-values-of-a-column-in-a-datatable">How to select min and max values of a column in a datatable?</a></p>
  
  <p>Sadly, I could not any to work. The one suggestion that kind of worked is shown in the second last line, but it returns a value of 8 or 9. Any suggestions as to how to properly get the results I am looking for?</p>
  
  <pre><code>        string filePath = System.IO.Path.GetFullPath(curriculum);
          DataTable curriculmDataTable = new DataTable();
  
          curriculmDataTable.Columns.Add("Id");
          curriculmDataTable.Columns.Add("Course");
          curriculmDataTable.Columns.Add("Credit");
  
          // Read in a file line-by-line, and store it
          var txtFileLine = File.ReadAllLines(filePath).ToList();
  
          //Reads line splits data to colums at tab (ASCII value 9)
          txtFileLine.ForEach(line =&gt; curriculmDataTable.Rows.Add(line.Split((char)9)));
  
  
          //Suggestions from link
          int max = Convert.ToInt32(curriculmDataTable.Select("Id=max(Id)")[0][0]);   
          label1.Text = ""+ max;
  </code></pre>