Diferença de data e hora em dias com base apenas na data

Eu preciso encontrar a diferença em dias entre duas datas.

Por exemplo:

Entrada:**startDate** = 12-31-2012 23hr:59mn:00sec, **endDate** = 01-01-2013 00hr:15mn:00sec

Produção esperada:1

Eu tentei o seguinte:

(dt1-dt2).TotalDays e converter em inteiro, mas não me deu resposta adequada, pois o dobro tem que ser convertido em Math.ceiling, Convert.To ...dt1.day - dt2.day não funciona em mesesdt.Substract() tem a mesma saída que a opção 1 mencionada acima.

Nenhum dos itens acima funcionou, então acabei escrevendo o seguinte código. O código funciona bem, mas acho que deve haver uma solução com apenas algumas linhas de código.

public static int GetDifferenceInDaysX(this DateTime startDate, DateTime endDate)
    {
        //Initializing with 0 as default return value
        int difference = 0;

        //If either of the dates are not set then return 0 instead of throwing an exception
        if (startDate == default(DateTime) | endDate == default(DateTime))
            return difference;

        //If the dates are same then return 0
        if (startDate.ToShortDateString() == endDate.ToShortDateString())
            return difference;

        //startDate moving towards endDate either with increment or decrement
        while (startDate.AddDays(difference).ToShortDateString() != endDate.ToShortDateString())
        {
            difference = (startDate < endDate) ? ++difference : --difference;
        }

        return difference;
    }

Observação: não tenho nenhum problema de desempenho na iteração while-loop, pois a diferença máxima não será superior a 30 a 45 dias.

questionAnswers(3)

yourAnswerToTheQuestion