The problem here is one of covariance .
First, your example is too complex. I removed a little fluff. In addition, I have added some diagnostic tools that illuminate the problem.
class Program { static void Main(string[] args) { var names = new[] { "Tom", "Dick", "Harry", "Mary", "Jay" }; var query = from n in names select new C { S = n };
The output of this program:
System.Collections.Generic.List`1 [C]
Note that we are trying to use List<C> to List<I> , which does not work in C # 3.0.
In C # 4.0, you can do this thanks to a new joint and opposite dispersion of type parameters on common interfaces.
Also, your original question asked IQueryable , but that doesn't matter: the query expression you specified creates an IEnumerable<string> not a IQueryable<string> .
EDIT . I want to point out that your "cast" using the as operator is technically not great, but is a "type conversion". If you used cast, you would get an exception to the helpful information. If I go to:
var list = (IList<I>)query.ToList();
I get an InvalidCastException with:
Additional Information: Cannot start an object of type 'System.Collections.Generic.List 1[C]' to type 'System.Collections.Generic.IList 1 [I]'.
source share