Exception can be thrown in two different ways.
? A throw statement (§15.9.5) throws an exception immediately and
unconditionally. Control never
reaches the statement immediately following the throw.
? Certain exceptional conditions that arise during the processing of C#
statements and expression cause an
exception in certain circumstances when the operation cannot be completed
normally. [Example: For
example, an integer division operation (§14.7.2) throws a
System.DivideByZeroException if the
denominator is zero. end example] See §23.4 for a list of the various
exceptions that can occur in this
way.
? A throw statement (§15.9.5) throws an exception immediately and
unconditionally. Control never
reaches the statement immediately following the throw.
? Certain exceptional conditions that arise during the processing of C#
statements and expression cause an
exception in certain circumstances when the operation cannot be completed
normally. [Example: For
example, an integer division operation (§14.7.2) throws a
System.DivideByZeroException if the
denominator is zero. end example] See §23.4 for a list of the various
exceptions that can occur in this
way.
本文介绍了C#中异常处理的两种方式:一是通过throw语句立即无条件地抛出异常;二是某些特殊条件下的操作可能导致异常发生,例如整数除法当分母为零时会引发System.DivideByZeroException。
1471

被折叠的 条评论
为什么被折叠?



