I’ve been meaning to learn C# and wanted sto write something like this Javascript code. How would i go about doing it

An example of what I’m trying to do:
Adding the first and last numbers until only two digits remain:

num = 1234567:

1+7 = 8

2+6 = 8

3+5 = 8

4 remains

So the first result is: 8884. Now everything is added again:

8+8 = 16

8+4 = 12

The result is 1612. Again everything is summed up:

1+2 = 3

6+1 = 7

The result is 37 – which is also the final result.

The Javascript code:

function sum(num) {
    var numString = num.toString();
    var newString = "";
    while (numString.length > 1) {
        newString += (parseInt(numString[0]) + parseInt(numString[numString.length - 1])).toString();
        numString = numString.substring(1, numString.length - 1);
    }
    newString += numString;

    if (newString.length > 2) {
        console.log(newString)
        return sum(newString);
    }  else {
         return newString;
      }
}