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

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -