What is the purpose of Nullable types in C#? Can we just assign a value of 0 instead of using null? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the purpose of Nullable types in C#? Can we just assign a value of 0 instead of using null?

I cannot seem to grasp the concept of Nullable type. Can someone enlighten me?

1st Aug 2017, 4:56 PM
Gerald Taccad Cauilan
Gerald Taccad Cauilan - avatar
1 Answer
+ 1
0 is a value, null means not set. If you bring 0 kids to a party, it means that you will come on your own or with a partner. If you bring null kids to a party, it means that you have not defined yet if you bring your kids or not.
1st Aug 2017, 8:43 PM
sneeze
sneeze - avatar