What is the meaning of the “Guid?” type?
Recently when working with the Entity Framework I had a parameter marked as ‘Guid?’, after reasearching the Internet this is what I came up with as to what a type is with a ‘?’ (question mark) character at the end:
? is use to assign null for premitive data types like int, string, Guid, etc.
So for example, you could do the following:
int? i = null;
However not this:
int i = null;
The last one would cause a compile error. So, why would you use this? Well, for the entity framework it makes sense as a non-initialized property is hard to identify. For example, in the case of an integer (Say property age) zero could be a valid value (just born), however, how do you distinguish between a valid zero and a non initialized integer? That’s when the null is helpful.