c# - Ways to Detect Digits Not Zero in an int? -



c# - Ways to Detect Digits Not Zero in an int? -

i curious if there simple ways observe number of non-zero digits in int/long. want create little programme formats input(standard numbers) scientific notation.

i've tried find int functions help this, i'm not 100% fluent , there weren't seemed help.

also, want find way set each digit int/long list each digit beingness it's own element. maybe there way there separate zero's non-zero's.

any fancy ideas (and comments) appreciated, thanks!

you turn string (using invariantculture) , count non 0 digits:

public int nonzerodigits(int input) { homecoming input.tostring(cultureinfo.invariantculture).count(digit => digit >= '1' && digit <= '9'); }

c# .net

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -