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:
- Difference between & and && ,| and ||
- Top 9 differences between Array and ArrayList in C#
- Difference between Var and Dynamic in c#
- Difference between RegisterClientScriptBlock and RegisterStartupScript asp.net
- Difference between ref and out parameters in C#
- Difference between static and non-static variable in C#
- Difference between Abstraction and Encapsulation in C#
- Difference between Throw and Throw ex in C#
- Difference between Hashtable and Dictionary
- Difference between Nullable<> and ?
- Difference between String and string in C#
- Difference Between WCF and WebAPI
- Difference between Abstract class and Interface in C#