OverflowException 类

在选中的上下文中所进行的算术运算、类型转换或转换操作导致溢出时引发的异常。

**命名空间:**System
**程序集:**mscorlib(在 mscorlib.dll 中)

语法

声明
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Class OverflowException
    Inherits ArithmeticException
用法
Dim instance As OverflowException
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public class OverflowException : ArithmeticException
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public ref class OverflowException : public ArithmeticException
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public class OverflowException extends ArithmeticException
SerializableAttribute 
ComVisibleAttribute(true) 
public class OverflowException extends ArithmeticException

备注

在检测到溢出的语言中,OverflowException 是被引发的异常。例如在 C# 中,被选中的关键字用于检测溢出条件。OverflowException 异常只在被选中的上下文中发生。

下面的 Microsoft 中间语言 (MSIL) 指令引发 OverflowException

  • add.ovf.<signed>

  • conv.ovf.<to type>

  • conv.ovf.<to type>.un

  • mul.ovf.<type>

  • sub.ovf.<type>

  • newarr

对于超出目标类型范围的整数或小数类型算术运算或转换的结果:

  • 在选中的上下文中,如果操作为常数表达式,则发生编译时错误。其他情况下,如果操作在运行时执行,则引发 OverflowException

  • 在未选中的上下文中将结果截断,方法是:丢弃任何不适应目标类型的高序位。

OverflowException 使用值为 0x80131516 的 HRESULT COR_E_OVERFLOW。

有关 OverflowException 实例的初始属性值列表,请参见 OverflowException 构造函数。

继承层次结构

System.Object
   System.Exception
     System.SystemException
       System.ArithmeticException
        System.OverflowException

线程安全

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

OverflowException 成员
System 命名空间
Exception 类

其他资源

处理和引发异常