.


:




:

































 

 

 

 


. .




.

nums[0]:

nums[1]: 1

nums[2]: 2

nums[3]: 3

!

.

nums int . for 0 9, IndexOutOfRangeException, 4.

, . -, , , try. -, ( nums for), try , catch. try catch. , catch , . , , WriteLine () for, , . , , .

, catch ( IndexOutOfRangeException), . , , . , , . , .

, try, catch , , catch. ,

for(int i=0; i < 10; i++) {

for(int i=0; i < nums.Length; i++) {

for. , catch .

, , try, , , try. , try, , , , .

, try Main (). GenException (), IndexOutOfRangeException. GenException (). GenException () try Main (), catch, try.

/* . */

Using System;

class ExcTest {

// , public static void GenException() {

int[] nums = new int [4];

Console.WriteLine(" .");

// .

for(int i=0; i < 10; i++) {

nums[i] = i;

Console.WriteLine("nums[{0}]: {1}", i, nums[i]);

}

Console.WriteLine("He ");

}

}

class ExcDemo2 {

static void Main() {

try {

ExcTest.GenException();

}

catch (IndexOutOfRangeException) {

// . 9

Console.WriteLine(" !");

}

Console.WriteLine(" .");

}

}





:


: 2016-12-03; !; : 335 |


:

:

, , . , .
==> ...

1380 - | 1218 -


© 2015-2024 lektsii.org - -

: 0.013 .