Why can't this cast be done?
I don't have a programming problem, but I'd like to know why.
I have something like this
List<MyClass> a,b,c<br /><br />var d = a.Except(b);<br />c.Clear()<br />c = d.ToList();
Of course, lists a & b are populated preceding the code. The question is, why can't I cast directly to List<myclass> as such:
<br />c = a.Except(b);<br />
You can't cast it as such because a.Except(b) returns the type
System.Linq.Enumerable.ExceptIterator. You have two options here:
c = a.Except(b).ToList();
because they're basically different types. a.Except(b) does not return a list, it returns an "Enumerable" type.
IEnumerable c List a,b c = a.Except(b)