I have propertyValuewhich is the object passed to my function.
I can assume that this is some kind IEnumerable, however, due to the interface contract, I have to accept it as object, rather than directly as IEnumerable.
When I try to pass my value in IEnumerable<object>, so that I can get the length I get InvalidCastException.
var length = ((IEnumerable<object>) propertyValue).Cast<object>().Count();
I get the following exception:
System.InvalidCastException: It is not possible to list an object of type 'System.String' to enter type 'System.Collections.Generic.IEnumerable`1 [System.Object]'.
source
share