The right way to compare a System.Double to '0' (a number, int?)

前端 未结 6 2101
遥遥无期
遥遥无期 2020-12-08 03:44

Sorry, this might be a easy stupid question, but I need to know to be sure.

I have this if expression,

void Foo()
{
    System.Double so         


        
6条回答
  •  没有蜡笔的小新
    2020-12-08 04:22

    If you simply want to suppress the warning, do this:

    if (something.Equals(0.0))
    

    Of course, this is only a valid solution if you know that drift isn't a concern. I often do this to check if I'm about to divide by zero.

提交回复
热议问题