In C#, is there a difference between default(Nullable<long>)
(or default(long?)
) and default(long)
?
Long
is just an example, it can be any other struct
type.
Well yes. The default value of a nullable or other reference type is null
while the default value for a long
or other value type is 0
(and any other members set to their defaults).
In this case:
default(Nullable<long>) == null
default(long?) == null
default(long) == 0L