difference-between-Nullable-questionmark-technothirsty

Difference between Nullable<> and ?

Difference between Nullable<> and ?

Hello friends, till now I have explained regarding different differences between. So I recommend you read all difference betweens. Today I am going to explain you regarding Difference between Nullable<> and ?.

Every one is having question which should we use from Nullable<> and ?. & which is better over either.

Let’s look into below code to find whether both are returning different values or behave differently!!!!

Nullable<int> a = null;
int? b = null;
a == b; // this is true

Ohh we can conclude that both are having same return value and both are equal in behavior. So why did microsoft has introduced both of them, if there is not any difference.

Let me give a example of difference between String and string,same way ? is the shorthand of Nullable<>.

If you look at the IL using Ildasm, you’ll find that they both compile down to Nullable.


Folks you should also refer below articles for better understanding of differences between confusing concepts: