C# Convert Char to Int
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:
dig = (int)Char.GetNumericValue(digit);
No Comments »
No comments yet.
RSS feed for comments on this post. TrackBack URL