In C#
int? a1 = 0; int? a2 = 100; a1 = a1 | default(int?); a2 = a2 | default(int?);
Both a1 and a2 turns out to be null. Would be great if someone would explain its working.
Update
The reason I brought up this insane example was the behavior when int? is replaced by bool? and the binding process.
bool? a1 = null; bool? a2 = true; a1 = a1 | default(bool?); a2 = a2 | default(bool?);
This piece of code does not give a warning saying the result of the expression is always null. The inferred reason is ‘I_dont_know’|int = ‘I_dont_know’ where as ‘I_dont_know’ | true = true
Correct me If I’m wrong
This is because of the following reasons..
http://msdn.microsoft.com/en-us/library/xwth0h0d%28v=vs.80%29.aspx
Btw, visual studio should complain that your expressions always resolve to null. (a warning).