According to the docs: http://msdn.microsoft.com/en-us/library/x13ttww7.aspx:
The volatile keyword can be applied to reference types.
So why is it illegal to use on a Nullable<T>
.. a reference type!
Please note that I do not actually need volatile semantics on a Nullable<T>
field, I encountered this error accidentally and am simply curious.
Nullable<T>
isn't a reference type. It's a value type:
public struct Nullable<T>
where T : struct, new()
Note the struct
part.
Just because it has a null
value doesn't make it a reference type... it's a nullable value type. See section 4.1.10 of the C# 4 language spec for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With