What should I do about “Possible compare of value type with ‘null'”?

Don’t change the code – just ignore the warning. If the type parameter is a non-nullable value type, the comparison will always fail and it’ll always call ToString() instead. I don’t know whether it’s actually JITted away, but I wouldn’t be surprised… and this doesn’t sound like it’s performance-critical code anyway 🙂

I’d personally leave the warning “on”, but ignore it in this particular case – possibly with a comment.

I think I came across the same warning a few times when reimplementing LINQ to Objects.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)