Once again I decided to make a new task from LeetCode and finally my process had been stopped. I could not convert Char to Int. I even spent some time for research, but I could not find any solution. Then I open the documentation and started to read.

So, in the class System there is a struct called Char. And there's a method GetNumericValue(char c).

As you could understand, it's easy to use it.

int dig = (int)Char.GetNumericValue(digit);

To use it more correct to avoid error I recommend to use this code:

        if (Char.IsDigit(digit))
            dig = (int)Char.GetNumericValue(digit);