ToArray

public static int[] ToArray(this int number)
{
    if (number == 0)
    {
        return new int[0];
    }
    else if (number < 0)
    {
        number = -1 * number;
    }

    List<int> list = new List<int>();
    while (number > 0)
    {
        list.Add(number % 10);
        number = number / 10;
    }
    list.Reverse();

    return list.ToArray();
}
Example:
int num = 87559;
int[] arr = num.ToArray();

Description

Returns an array of int containing all caracters that compose the number.

Details

Double click on the code to select all.

 

;