我希望我的程序在某个浮点变量达到无穷大时抛出异常,或者是Nan NotFiniteNumberException,它看起来像是一个解决方案,但是存在问题.这个
try
{
Single x = 5;
x = x / 0;
x = x + 1;
}
catch (NotFiniteNumberException ex)
{
//bla bla bla
}
Run Code Online (Sandbox Code Playgroud)
不会抛出任何东西.
我知道IsNan和IsInfinity方法,但这不是我想要的.