My code is...
public static void AssertNotNull<T>(string name, T val) {
if (val == null)
throw new ArgumentNullException(String.Format("{0} must not be null", name));
}
Resharper is recommending...
public static void AssertNotNull<T>(string name, T val) {
if (Equals(val, default(T)))
throw new ArgumentNullException(String.Format("{0} must not be null", name));
}
Because it doesn't know if T
is a value type or reference type, so it makes the code work with both.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With