本文共 2538 字,大约阅读时间需要 8 分钟。
c#异常处理
Correct answer: 3final
The final keyword is not used to handle exceptions in C#.NET.
正确答案:3 最后
final关键字不用于处理C#.NET中的异常。
Correct answer: 2throw
The throw is a valid keyword used in exception handling.
正确答案:2 扔
throw是异常处理中使用的有效关键字。
Correct answer: 2The throw keyword is used to throw an exception object programmatically
The 2nd statement is correct about throw keyword.
正确答案:2 throw关键字用于以编程方式引发异常对象
关于throw关键字的第二条语句是正确的。
using System;namespace my_namespace{ class program { static void Main(string[] args) { int a = 0; int b = 10; int c = 0; try { c = b / a; } catch (DivideByZeroException d) { Console.WriteLine("Divide by zero exception occurred"); } } }}
Correct answer: 1Divide by zero exception occurred
The above code will print "Divide by zero exception occurred" on the console screen.
正确答案:1 除零发生异常
上面的代码将在控制台屏幕上显示“发生零除零异常”。
using System;namespace my_namespace{ class program { static void Main(string[] args) { int a = 0; int b = 10; int c = 0; try { c = b / a; } finally { Console.WriteLine("Finally executed"); } } }}
Correct answer: 1Yes, finally will execute
Yes, finally block will execute.
The output would be,
using System ;namespace my_namespace{ class program { static void Main ( string [ ] args ) { int a = 0 ; int b = 10 ; int c = 0 ; try { c = b / a ; } finally { Console . WriteLine ( " Finally executed " ) ; } } }}
正确答案:1 是的,最后会执行
是的,finally块将执行。
输出将是
翻译自:
c#异常处理
转载地址:http://hctzd.baihongyu.com/