3 ms·
Well, Depends on which type you are referring to (Which is part of what pains me with nullable ref types, as nice as it is to have) If it's a value type (T), ?
by to11mtm 7y ago
Well, Depends on which type you are referring to (Which is part of what pains me with nullable ref types, as nice as it is to have)
If it's a value type (T), ? will make it Nullable<T> and provide the behavior described.
Reference types however can always be null, and do not have a .HasValue as exampled above. However newer versions of C# let you declare nullable references on a compiler level, but rather than HasValue/Value you still have to do the null check and instead can bypass via the new deref operator (!)
- LorenPechtel 7y agoWhich is what I was talking about. I haven't had the opportunity to put it to use yet (converting an existing project is a big headache, it's something to do from the start) so I didn't remember the terms, only the ability.