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 1415
感动是毒
感动是毒 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:21

    int can never be equal to null. int? is the nullable version, which can be equal to null.

    You should check if(arrTopics.Count() != 0) instead.

提交回复
热议问题