Split number into hundreds tens and units using C#

前端 未结 5 1055
星月不相逢
星月不相逢 2021-01-03 13:00

What is the best way to split some given larger number into hundreds, tens and units in C#?

For example: If I enter number 43928 how can I get 40000 + 3000 + 900 + 2

5条回答
  •  渐次进展
    2021-01-03 13:14

    You have to use the % operator. Example: 43928 / 10000 = 4; 43928 % 10000 = 3928; 3928 /1000 = 3; 3928 %1000 = 928, etc...

提交回复
热议问题