DateTime.AddDays in a While loop. What am I missing?
<p>I have a datetime object, <code>dt</code>,  that holds today's date.   </p>

<pre><code>DateTime dt = DateTime.Today;
DateTime idt = new DateTime();
</code></pre>

<p>I need to print the date when the loop reaches last day of the current year, like this:<br>
 <code>345 more days to 12/31/2012</code></p>

<p>If I do it this way  </p>

<pre><code>while (dt.AddDays(i).Year == dt.Year) 
{
    idt = dt.AddDays(i);
    i++;
}
Console.WriteLine("{0} more days to {1}", i, idt.ToString("d")); 
</code></pre>

<p>I am able to get it to print like I want:  <code>345 more days to 1/1/2012</code></p>

<p>I want to avoid the repetition of <code>dt.AddDays(i)</code> in the above part. If I do it either this way:  </p>

<pre><code>while (idt.Year != dt.Year + 1)
{
    idt = dt.AddDays(i);
    i++;
}
Console.WriteLine("{0} more days to {1}", i, idt.ToString("d"));
</code></pre>

<p>or this way:  </p>

<pre><code>while (idt.Year &lt; 2013)
{
    idt = dt.AddDays(i);
    i++;
} 
Console.WriteLine("{0} more days to {1}", i, idt.ToString("d"));
</code></pre>

<p>I get the output as <code>346 more days to 1/1/2013</code>.   </p>

<p>I am definitely missing something painfully obvious, but I am unable to figure out. What would it be?  </p>
