c# going through an int and adding every character to a sum
<pre><code>while (sum != 0)
{
    n += sum % 10;
    sum /= 10;
}
</code></pre>

<p>I know what the code does, but can someone explain me how it works?</p>