These are all equivalent according to the specification:
4.1.10 Nullable types
An instance for which HasValue is false is said to be null. A null instance has an undefined value
4.1.2 Default constructors
All value types implicitly declare a public parameterless instance constructor called the default constructor. The default constructor returns a zero-initialized instance known as the default valuefor the value type:
• For a struct-type, the default value is the value produced by setting all value type fields to their default value and all reference type fields to null.
nullable types are structs and HasValue
is a bool with a default value of false
so new int?()
is null.
5.2 Default values
The default value of a variable depends on the type of the variable and is determined as follows:
• For a variable of a value-type, the default value is the same as the value computed by the value-type’s default constructor (§4.1.2).
so default(int?)
is equivalent to new int?()