title: Calculate Average from Data Table colmns
body: <p>Trying to manipulate the data in the following datatable to allow me to calculate averages.</p>
  
  <p>I want to add all the data in PktsRecieved(XAxis) and PktsRecieved(YAxis) and calculate an average</p>
  
  <p>Should I use a Linq query or what is the best way of doing this</p>
  
  <p>Thanks</p>
  
  <pre><code>List&lt;string[]&gt; rows = File.ReadAllLines(@"E:\\Final Year\\Uni\\NoCAnalysisTool2\\rx.csv")
     .Select(x =&gt; x.Split(','))
     .ToList();
  
  DataTable dt = new DataTable();
  
  dt.Columns.Add("Source|Destination");
  dt.Columns.Add("PktsRecieved(XAxis)");
  dt.Columns.Add(" ");
  dt.Columns.Add("Source|Destination ");
  dt.Columns.Add("PktsRecieved(YAxis)");
  dt.Columns.Add("");
  dt.Columns.Add("");
  dt.Columns.Add("");
  
  
  rows.ForEach(x =&gt; { dt.Rows.Add(x); });
  dataGridView2.DataSource = dt;
  </code></pre>