Search code examples
.netnulldbnull

(any == System.DBNull.Value) vs (any is System.DBNull)


Does any one have a preference on how to check if a value is DBNull? I've found these two statements give me the results I want, but just wondering if there's a preference?

if (any is System.DBNull)

same as:

if (any == System.DBNull.Value)

Thanks!


Solution

  • if (any == System.DBNull.Value) ...
    

    I prefer that one, simply because I read that as comparing values, not types.