How to count the number of digits in a number in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        int num = 18092;
        int len = (int)Math.Log10(num) + 1;

        Console.Write(len);
    }
}



 
 
/*
run:
 
5
 
*/

 



answered Jul 23, 2021 by avibootz

Related questions

1 answer 114 views
1 answer 114 views
2 answers 165 views
1 answer 136 views
1 answer 171 views
1 answer 115 views
115 views asked Apr 24, 2017 by avibootz
1 answer 226 views
...