sum the digits in c#

C#
sum = 0;
while (n != 0) {
    sum += n % 10;
    n /= 10;
}
Source

Also in C#: