c# - can i pass in IQueryable<Foo> into IQueryable<IFoo> if the object implements that interface? -
i have object a: iqueryable<foo> and want pass function expects a: iqueryable<ifoo> foo implements ifoo why wouldn't compile? best way convert have work? co- , contra- variance added in .net 4 bcl, , not exist in .net 3.5 bcl. you can work around limitation in 3.5 using select operation cast interface type: iqueryable<foo> foos = ..; myfunc(foos.select(x => (ifoo)x)); edit (from reed's comment, below): iqueryable<foo> foos = ..; myfunc(foos.cast<ifoo>());