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?"

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.


It means what it says.

The "Count" method returns a value type. It's an integer. It will always have a value where it's default value is zero.

Your check really should be:

if (arrTopics.Count() != 0)

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.

Tags:

C#

Arrays