I am trying to call IEnumerable.Contains()
with a dynamic
argument, but I am getting the error
'IEnumerable' does not contain a definition for 'Contains' and the best extension method overload 'Queryable.Contains(IQueryable, TSource)' has some invalid arguments
I've noticed that I can either cast the argument to the correct type, or use an underlying collection type to fix the issue. But I'm not sure why I can't just pass in the argument directly.
dynamic d = "test";
var s = new HashSet<string>();
IEnumerable<string> ie = s;
s.Contains(d); // Works
ie.Contains(d); // Does not work
ie.Contains((string)d); // Works