DEV Community

loading...

Discussion on: The perfect non-null test

Collapse
ahmaddeel profile image
AhmadDeel

Is object different from struct? What if we have struct and "is object" fails?

Collapse
peledzohar profile image
Zohar Peled Author

object is the ultimate base type for all .Net types. structs implicitly inherits the ValueType class which inherits object, and by definition are value types, meaning they can't be null to begin with - which means that this test will always return true.