.net - How to check the number is among the sets of numbers in C# -
i have condition like:
if x between (1 4) ----- value 0 if x between(4 8) ----- value 1 if x between(8 12) ----- value 2 if x between(12 16) ----- value 3
and on....
what best way in c#?
integer division in c# truncates, if number talking integer , assigned variable myint, have write expression this:
(myint -1) / 4
.
and if number float, casting int truncates, cast this:
((int) myfloat - 1) /4
Comments
Post a Comment