c# - How to count all digits after 2 digits, but before the decimal? -


decimal n = str.split('.')[0].substring(2).where(d => d == '0').count(s => s == '0');                             displaylabel5.text = n.tostring(); 

this code works, counts zeros after first 2 digits input. after enter, let's say, 5360000. output 4 because there 4 zeroes. want count 6 because isnt apart of first 2 numbers.

the following code takes characters before decimal mark '.' skips first 2 , counts remaing ones.

var test = "335434553.23434"; var result = test.takewhile(d => d != '.').skip(2).count(); 

note code assumes dealing string represents valid number.


Comments

Popular posts from this blog

java - Solr query version issue: Invalid version or the data in not in 'javabin' format -

Hard vs. Soft Water: What's The Difference?

The Ten Most Livable Cities In The World