Calculating how many minutes there are between two times
<p>I have a datagridview in my application which holds start and finish times.  I want to calculate the number of minutes between these two times.  So far I have got:</p>

<pre><code>var varFinish = tsTable.Rows[intCellRow]["Finish Time"];
TimeSpan varTime = (DateTime)varFinish - (DateTime)varValue;
int intMinutes = TimeSpan.FromMinutes(varTime);
</code></pre>

<p>But the last line won't compile because it says I am using invalid arguments for the Timespan constructor.  I've researched quite a bit about how to calculate the number of minutes between two times, but I'm hitting a bit of a brick wall.  Can someone please advise me on the best way to achieve my objective.</p>

<p>EDIT/</p>

<p>Now my code is as follows:</p>

<pre><code>var varFinish = tsTable.Rows[intCellRow]["Finish Time"];
TimeSpan varTime = (DateTime)varFinish - (DateTime)varValue;
int intMinutes = (int)varTime.TotalMinutes;
</code></pre>

<p>But I am getting an invalid cast on the second line.  Both varFinish and varValue are times e.g. 10:00 and 8:00 say.  So not sure why they won't cast to type DateTime?</p>
