The following is a simplified version of the problem I'm having:
var list = new List<int> {1, 2, 3, 4, 5};
// list Count = 5 System.Collections.Generic.List<int>
var obj = list as object;
// obj Count = 5 object {System.Collections.Generic.List<int>}
var enumerable = obj as IEnumerable<object>;
// enumerable null System.Collections.Generic.IEnumerable<object>
The comments are the values from the watch window in Visual Studio 2017
However if I enter:
obj as IEnumerable<object>
in the watch window, I get:
obj as IEnumerable<object> Count = 5 System.Collections.Generic.IEnumerable<object> {System.Collections.Generic.List<int>}
So how come I can cast it in the watch window and it works, but if I do it in the code it evaluates to null?