Disable compiler warning : Warning « Development « C# / CSharp Tutorial






using System;
using System.Collections;
using System.Runtime.CompilerServices;

[assembly: RuntimeCompatibility(WrapNonExceptionThrows = false)]
public class MainClass
{
    static void Main() {
        try {
            ArrayList list = new ArrayList();
            list.Add( 1 );

            Console.WriteLine( "Item 10 = {0}", list[10] );
        }
        catch( ArgumentOutOfRangeException x ) {
            Console.WriteLine( x );
            Console.WriteLine( "ArgumentOutOfRangeException Handler" );
        }
        catch( Exception x ) {
            Console.WriteLine( x );
            Console.WriteLine( "Exception Handler" );
        }
        catch {
            Console.WriteLine( "An exception I was not expecting..." );
            Console.WriteLine( "Unexpected Exception Handler" );
        }
        finally {
            Console.WriteLine( "Cleaning up..." );
        }
    }
}
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the s
ize of the collection.
Parameter name: index
   at System.Collections.ArrayList.get_Item(Int32 index)
   at MainClass.Main()
ArgumentOutOfRangeException Handler
Cleaning up...








14.31.Warning
14.31.1.Disable compiler warning