title: Algorithm to detect overlapping periods
body: <p>I've to detect if two time periods are overlapping.<br/>
  Every period has a start date and an end date.<br/>
  I need to detect if my first time period (A) is overlapping with another one(B/C). <br/>
  In my case, if the start of B is equal to the end of A, they are not overlapping(the inverse too) <br/>
  I found the following cases:</p>
  
  <p><img src="https://i.stack.imgur.com/AIBUV.png" alt="enter image description here"></p>
  
  <p>So actually I'm doing this like this:</p>
  
  <pre><code>tStartA &lt; tStartB &amp;&amp; tStartB &lt; tEndA //For case 1
  OR
  tStartA &lt; tEndB &amp;&amp; tEndB &lt;= tEndA //For case 2
  OR
  tStartB &lt; tStartA  &amp;&amp; tEndB &gt; tEndA //For case 3
  </code></pre>
  
  <p>(The case 4 is taken in the account either in case 1 or in case 2)</p>
  
  <p>It <strong>works</strong>, but it seems not very efficient.</p>
  
  <p>So, first is there an existing class in c# that can modelize this(a time period), something like a timespan, but with a fixed start date.</p>
  
  <p>Secondly: Is there already a c# code(like in the <code>DateTime</code> class) which can handle this?</p>
  
  <p>Third: if no, what would be your approach to make this comparison the most fast?</p>