// Recursive Solution:
public Stack<int> NumbersIn(int value)
{
if (value == 0) return new Stack<int>();
var numbers = NumbersIn(value / 10);
numbers.Push(value % 10);
return numbers;
}
var numbers = NumbersIn(987654321).ToArray();
// Without Recursion:
public int[] NumbersIn(int value)
{
var numbers = new Stack<int>();
for(; value > 0; value /= 10)
numbers.Push(value % 10);
return numbers.ToArray();
}
// without LINQ (see linked source for more solutions with or w/o LINQ
public static IEnumerable<int> GetDigits(int source)
{
int individualFactor = 0;
int tennerFactor = Convert.ToInt32(Math.Pow(10, source.ToString().Length));
do
{
source -= tennerFactor * individualFactor;
tennerFactor /= 10;
individualFactor = source / tennerFactor;
yield return individualFactor;
} while (tennerFactor > 1);
}