Why am I getting “CS0472: The result of the expression is always true since a value of type int is never equal to null of type int?”

后端 未结 9 1416
感动是毒
感动是毒 2020-12-20 12:09
string[] arrTopics = {\"Health\", \"Science\", \"Politics\"};

I have an if statement like:

 if (arrTopics.Count() != null)
<         


        
9条回答
  •  一整个雨季
    2020-12-20 12:26

    null represents the absence of any value, not the number 0. And as the message says an int can never be null since it's neither a reference type nor a nullable value type and thus always has some value.

提交回复
热议问题