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
The way with the parsing:
var myBigNumber = 43928.ToString();
var asCharachters = myBigNumber.ToArray();
for (var i = 0; i < asCharachters.Length; i++)
{
var numberOfZeros = asCharachters.Length - i;
var itemAsString = (asCharachters[i]).ToString().PadRight(numberOfZeros, '0');
Console.WriteLine( Int32.Parse(itemAsString));
}
Outputs this:
40000
3000
900
20
8