lance lance - 1 month ago 5x
C# Question

check against: null vs default()?

I want to check if a reference type is null. I see two options (_settings is of reference type FooType):

if (_settings == default(FooType)) { ... }


if (_settings == null) { ... }

How do these two perform differently?


There's no difference. The default value of any reference type is null.

MSDN's C# reference page for default keyword: