Catch OutOfMemoryException

image_pdfimage_print
   



using System;
   
class MainClass
{
    public static void Main()
    {
        int [] LargeArray;
   
        try
        {
            LargeArray = new int [2000000000];
        }
        catch(OutOfMemoryException)
        {
            Console.WriteLine("The CLR is out of memory.");
        }
    }
}