title: C# DateTime Extension Method
body: <p>I was asked to extend the type DateTime by Extension Method.
  Then i need to create a method that will check if the month value added is my birth day, and if not it will tell me how many months left till my birth day.
  I tried to create the following class for the DateTime extention, with the extension method inside.</p>
  
  <p>I just got lost with the birth day month calculation inside that method</p>
  
  <p>Should be something like:</p>
  
  <pre><code>public static class MyDateTimeExtension
  {
      public static DateTime Month(this DateTime DiffDT)
      {
          DateTime BirthdayMonth;
          DateTime CurrentMonth;
          return DiffDT = BirthdayMonth - CurrentMonth;
      }
  }
  </code></pre>
  
  <p>or something like</p>
  
  <pre><code>        return DiffDT.AddMonths = BirthdayMonth.AddMonths - CurrentMonth.AddMonths;
  </code></pre>
  
  <p>But ofcourse this code can't compile.
  After creating the extension methos i should call the method from the main class with new DateTime variable</p>
  
  <pre><code> DateTime DT;
   Console.WriteLine(DT.Month());
  </code></pre>
  
  <p>Hope this helps to understand</p>