Finding the string length of a integer in .NET
- by James Newton-King
In .NET what is the best way to find the length of an integer in characters if it was represented as a string?
e.g.
1 = 1 character
10 = 2 characters
99 = 2 characters
100 = 3 characters
1000 = 4 characters
The obvious answer is to convert the int to a string and get its length but I want the best performance possible without the overhead of creating a new string.