Project Euler 19 (count Sundays in the 20th Century) with a while loop
Your logic is checking about Number of Days in Month, Leap year and related date logic.

Following snippet will work. This logic will loop thru the each month(1 to 12) with in 20th century and  and checks first day of month is Sunday or not. 

      var result = 0;
        for(int year =  1901; year &lt;= 2000; year++)
        {
            for(int month = 1;month&lt;=12;month++)
            {
                if (new DateTime(year, month, 1).DayOfWeek == DayOfWeek.Sunday)
                    result++;
            }
        }
        Console.WriteLine(result);