Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get digits in an integer [duplicate]

Tags:

c#

Is there any way to get the number of digits in an integer? For example:

int a = 12345;

I want to determine that a has 5 digits

like image 678
sinhaya Avatar asked Nov 25 '25 18:11

sinhaya


1 Answers

int a = 12345;
int length = a.ToString().Length;      // returns 5
like image 130
Timwi Avatar answered Nov 28 '25 06:11

Timwi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!