This code will not compile:
var x = new {
Property = null,
};
With following exception: Cannot assign null to anonymous type property
But this will work fine:
var someBool = false;
var x = new {
Property = someBool ? "value" : null,
};
I think there is implicit casting something like this - (string)null but not exactly sure.
So I would like to know more about this case and how this works internally (I didn't find any article explaining this)