Length

public static int Length(this int i)
{
    if (i <= 0) throw new ArgumentOutOfRangeException();

    return (int)Math.Floor(Math.Log10(i)) + 1;
}
Example:
int ir = 84372;

Console.WriteLine(ir.Length()); //will write 5

Description

Determines how many numbers compose the integer if it was represented as a string.

Details

Double click on the code to select all.

 

;