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 1438
感动是毒
感动是毒 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:41

    Null is a special pointer value, and not an integer. There are nullable types, that are either null or one of the possible values for the base type, but int itself is not nullable.

提交回复
热议问题