According to the documentation of the as
operator, as
"is used to perform certain types of conversions between compatible reference types". Since Nullable is actually a value type, I would expect as
not to work with it. However, this code compiles and runs:
object o = 7;
int i = o as int? ?? -1;
Console.WriteLine(i); // output: 7
Is this correct behavior? Is the documentation for as
wrong? Am I missing something?