title: c# check if a timespan range is between timespan range and how many hours
body: <p>Assuming I have 3 time ranges:</p>
  
  <pre class="lang-none prettyprint-override"><code>07:00 - 18:00  
  18:00 - 23:00  
  23:00 - 07:00  
  </code></pre>
  
  <p>and the code:</p>
  
  <pre><code>public class TimeShift
  {
     public TimeSpan Start { get; set; }
     public TimeSpan End { get; set; }
  }
  
  List&lt;TimeShift&gt; shifts = new List&lt;TimeShift&gt;();
  </code></pre>
  
  <p>How can I check if every item in the list is between the 3 ranges above and how many hours?</p>
  
  <p>For example one <code>TimeShift</code> where:</p>
  
  <pre class="lang-none prettyprint-override"><code>Start: 07:00
  End:   23:30
  </code></pre>
  
  <p>then that means 16.5 hours.</p>
  
  <p>For the examples above:</p>
  
  <pre class="lang-none prettyprint-override"><code>Range 1: 11 hours  
  Range 2: 5 hours  
  Range 3: 0.5 hours  
  </code></pre>