How can I get a count of the total number of digits of a number in C#? For example, the number 887979789 has 9 digits.
The answer of Steve is correct, but it doesn't work for integers less than 1.
Here an updated version that does work for negatives:
int digits = n == 0 ? 1 : Math.Floor(Math.Log10(Math.Abs(n)) + 1)