```
class Program
{
    static void Main(string[] args)
    {
        int temp;
        int arm, j = 0;
        List<int> armstrongnos = new List<int>();
        for (int i = 1; i < 1000; i++)
        {
            arm= 0;
            temp = i;
            while (i > 0)
            {
                arm += (i % 10) * (i % 10) * (i % 10);
                i /= 10;
            }
            if (arm== temp)
            {
                armstrongnos.Add(temp);// OutOfMemory Exception occurs whether you use array or list.
            }
        }
        foreach (var item in armstrongnos)
        {
            Console.WriteLine(item);
        }
        Console.ReadLine();
    }
}

```

I'm trying to print armstrong no.s b/w 1 to 1000. In the above code after it is confirmed that it is a armstrong no. I am assigning those values to array or List. But I am having the outofMemory Exception in both the cases. 
Couldn't understand why this issue arise.
Please help to fix the issue. 
What am I doing wrong in this Code. Please explain.