Pick Birthdays between 2 dates Irrespective of Year of Birth in C#

Many times we come across situations where we have to get birthdays of employees between 2 given dates irrespective of year of birth.

Here is a small piece of code in c# that does the trick:
  1. public bool IsBirthdayBetweenDates(DateTime birthdate, DateTime beginDate, DateTime endDate)  
  2. {  
  3.      if (birthdate != null & beginDate != null && endDate != null)  
  4.      {  
  5.          DateTime temp = birthdate.AddYears(beginDate.Year - birthdate.Year);  
  6.    
  7.          if (temp < beginDate)  
  8.          {  
  9.              temp = temp.AddYears(1);  
  10.          }  
  11.          return birthdate <= endDate && temp >= beginDate && temp <= endDate;  
  12.      }  
  13.      return false;  
  14. }  
Here beginDate is the start date for search
endDate: end date for search

The logic is simple,Just bring the birthdate to the year of begindate by adding years and then compare the dates.