小编Ada*_*rny的帖子

C#NotFiniteNumberException不起作用

我希望我的程序在某个浮点变量达到无穷大时抛出异常,或者是Nan NotFiniteNumberException,它看起来像是一个解决方案,但是存在问题.这个

try
{
    Single x = 5;
    x = x / 0;
    x = x + 1;
}
catch (NotFiniteNumberException ex)
{
    //bla bla bla 
}
Run Code Online (Sandbox Code Playgroud)

不会抛出任何东西.

我知道IsNanIsInfinity方法,但这不是我想要的.

c# floating-point exception

2
推荐指数
1
解决办法
1767
查看次数

标签 统计

c# ×1

exception ×1

floating-point ×1