Nullable<int> vs. int? - Is there any difference?

.net, c#

Solution

No difference.

`int?` is just shorthand for `Nullable<int>`, which itself is shorthand for `Nullable<Int32>`.

Compiled code will be exactly the same whichever one you choose to use.

Problem

Apparently `Nullable<int>` and `int?` are equivalent in value. Are there any reasons to choose one over the other? ``` Nullable<int> a = null; int? b = null; a == b; // this is true ```

Original source

Related problems