I'm having a weird behaviour trying to get the value of a boolean property stored at HttpContext.Current.Session.
The object is a boolean. First I'm trying to check if the object exists and, if exists, use it.
I'm trying to use it in a ?:
operator but it behaves strange. Here is my Watch window:
Premise
- The
"ExistingKey"
key exists and has a value of false (if key doesn't exists returns false).
Results
- When checking if
!=null
it returns false (first thing weird). - When using the
?:
operator, besides the condition is false, it returns the first expression, 4 (second thing weird).
Could somebody explain this behaviour?
Note: I'm not asking for an alternative to bypass this situation. Just asking why this works like this.