How to get the highest value from a datatable?
<p>I have a <code>datatable</code> which has a few columns. I want to return the one which matches my id, with the highest value in the <code>verlabel</code> column, in this case I want to return 1.1</p>

<p><img src="https://i.stack.imgur.com/R2iKu.png" alt="Datatable structure"></p>

<p>How do I achieve this? Current code just returns the column name into my string variable, rather than the actual value.</p>

<pre><code>Namespace.EnquiryEngine.DataLists ds2 = new Namespace.EnquiryEngine.DataLists("VERSION");
Namespace.Common.KeyValueCollection ds2params = new Namespace.Common.KeyValueCollection();
ds2params.Add("id", class.ID); 
ds2.ChangeParameters(ds2params);
System.Data.DataTable dt = ds2.Run(false) as System.Data.DataTable;
String version = Convert.ToString(dt.Rows[0]["version"]);
</code></pre>

<p>New code:</p>

<pre><code>var highestVersion = (from row in dt.AsEnumerable() 
                  where row.Field&lt;int&gt;("id") == doc.ID
                  select row.Field&lt;double&gt;("verlabel")).Max();
</code></pre>