.


:




:

































 

 

 

 


. .




.

.

try/catch.

, DivideByZeroException new throw. , , , . , . DivideByZeroException , , .

, catch, , catch. . , - , . throw , .

Throw;

, , , , catch, catch.

.

IndexOutOfRangeException.

// .

Using System;

class Rethrow {

public static void GenException() {

// numer denom.

int[] numer = { 4, 8, 16, 32, 64, 128, 256, 512 };

int[] denom = { 2, 0, 4, 4, 0, 8 };

try {

Console.WriteLine(numer[i] + " / " +

denom[i] + " " + numer[i]/denom[i]);

}

catch (DivideByZeroException) {

Console.WriteLine(" !");

}

catch (IndexOutOfRangeException) {

Console.WriteLine(" ."); throw; //

}

}

}

}

class RethrowDemo { static void Main() { try {

Rethrow.GenException ();

}

catch(IndexOutOfRangeException) {

//

Console.WriteLine(" - .");

}

}

}

- GenException (), . IndexOutOfRangeException Main ().

finally

, try/catch. , , . , , , . , C# : finally.

, try/catch, finally try/catch. try/ catch finally.

try {

// , .

}

catch (ExcepTypel exOb) {

// ExcepTypel.

}

catch (2 ) {

// 2. }

finally {

// .

}

finally , try/ catch, , . , try , , finally. finally , try catch .





:


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


:

:

, , .
==> ...

1652 - | 1319 -


© 2015-2024 lektsii.org - -

: 0.012 .