So, I do a lot of work with databases in the application - and there are several possible return values ββfor my caching system. It can return null, it can return a default value (type), or it can return an invalid object (invalid object, I mean one with incorrect properties / values). I want to create an extension method to do all of these checks for me, for example:
public static bool Valid<T> (this T obj) where T: class { if (obj == null) return false; else if (obj == default(T)) return false;
The problem is that my compiler tells me that if (obj == default(T)) will always be false.
Why is this?
c # linq resharper null-check
caesay
source share