i have an object that is a:
IQueryable<Foo>
and i want to pass it into a function that expects a:
IQueryable<IFoo>
Foo DOES implements IFoo
why wouldn’t this compile? what is the best way to convert to have this work?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Co- and contra- variance were added in the .NET 4 BCL, and do not exist in the .NET 3.5 BCL.
You can work around this limitation in 3.5 by using the
Selectoperation to cast to your interface type:Edit (from Reed’s comment, below):