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
Post a Comment