title: Calculate min and max C#
body: <p>I'm trying to work out Max value from the datagridview.
  Here is my whole code:</p>
  
  <pre><code>namespace WindowsFormsApplication2
  {
  public partial class Form1 : Form
  {
      public Form1()
      {
          InitializeComponent();
      }
  
      public class HRData
      {
          public int? HeartRate
          {
              get;
              set;
          }
          public int? Speed
          {
              get;
              set;
          }
          public int? Power
          {
              get;
              set;
          }
          public int? Altitude
          {
              get;
              set;
          }
  
          public override string ToString()
          {
              return String.Format("Heart rate={0}, Speed={1}, Power={2}, Altitude={3}", HeartRate, Speed, Power, Altitude);
          }
      }
  
  
  
  
  
      public static class HRDataReader
      {
          static private int? ConvertValue(string[] values, int index)
          {
              if (index &gt;= values.Length)
                  return null;
              int value;
              if (int.TryParse(values[index], out value))
                  return value;
              return null;
          }
  
          static public IList&lt;HRData&gt; Read(string fileName)
          {
              if (string.IsNullOrEmpty(fileName))
                  throw new ArgumentNullException("fileName");
              using (StreamReader sr = new StreamReader(fileName))
              {
                  string line;
  
                  // First: Skip to the correct section.
                  while ((line = sr.ReadLine()) != null)
                      if (line == "[HRData]")
                          break;
  
                  // Now: Read the HRData
                  List&lt;HRData&gt; data = new List&lt;HRData&gt;();
                  while ((line = sr.ReadLine()) != null)
                  {
                      if (line.StartsWith("[") &amp;&amp; line.EndsWith("]"))
                          break;
                      line = line.Trim().Replace("\t", " "); // Remove all tabs.
                      while (line.Contains("  ")) // Remove all duplicate spaces.
                          line = line.Replace("  ", " ");
                      string[] values = line.Split(' '); // Split the line up.
                      data.Add(new HRData
                      {
                          HeartRate = ConvertValue(values, 0),
                          Speed = ConvertValue(values, 1),
                          Power = ConvertValue(values, 2),
                          Altitude = ConvertValue(values, 3)
                      });
                  }
                  return data;
              }
          }
      }
  
  
      private void Form1_Load(object sender, EventArgs e)
      {
  
      }
  
      private void button1_Click_1(object sender, EventArgs e)
      {
          if (openFileDialog1.ShowDialog() == DialogResult.OK)
          {
              dataGridView1.Rows.Clear();
              dataGridView1.Columns.Clear();
  
              IList&lt;HRData&gt; data = HRDataReader.Read(openFileDialog1.FileName);
  
              dataGridView1.Columns.Add(new DataGridViewTextBoxColumn { Name = "HeartRate", HeaderText = "Heart rate", DataPropertyName = "HeartRate" });
              dataGridView1.Columns.Add(new DataGridViewTextBoxColumn { Name = "Speed", HeaderText = "Speed", DataPropertyName = "Speed" });
              dataGridView1.Columns.Add(new DataGridViewTextBoxColumn { Name = "Power", HeaderText = "Power", DataPropertyName = "Power" });
              dataGridView1.Columns.Add(new DataGridViewTextBoxColumn { Name = "Altitude", HeaderText = "Altitude", DataPropertyName = "Altitude" });
  
              dataGridView1.DataSource = data;
  
              int maxSpeed = Speed.Max();
              maxSpeed = maxSpeed / 10;
              string MaxSpeed = Convert.ToString(maxSpeed);
              textBox1.Text = MaxSpeed;    
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I'm getting an error on 'int maxSpeed = Speed.Max();'</p>
  
  <p>The error message says that "The name 'Speed' does not exist in a current context"</p>
  
  <p>I don't know what value should I put in there to represent one of my columns. Hope someone will be able to help me with this issue. Thank You.</p>