c# - How to slice or separate integer numbers and assign them to different variables -


for example, if have variable:

uint version = 001001020; 

this version has 9 digits, , want divide them 3 variables.

  • the first variable have 001
  • the second variable have 001 and
  • the third variable have 020

i tried using slice this:

first_variable = version.slice(0,6) second_var = version.slice(3,3) third_var = version.slice(6,0) 

it seems work on strings, not uint.

you can want division , remainder:

uint first_variable = version / 1000000; uint second_variable = (version / 1000) % 1000; uint third_variable = version % 1000; 

/ 1000000 shift number 6 digits right, discarding rightmost digits, , % 1000 keep whatever below 1000.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -