Csharp/CSharp Tutorial/Development/Warning — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 15:31, 26 мая 2010
Disable compiler warning
using System;
using System.Collections;
using System.Runtime.rupilerServices;
[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...