Specified cast is not valid at System.Linq.Enumerable. MoveNext

Yes, it's true. Pseudo-code below will not work with buildin types (int, long, double and so on) with InvalidCastException.


int[] a = new int[]{ 1, 2, 3 };

IEnumerable<double> d = a.Cast<double>();


foreach (double x in d) {

System.Console.WriteLine(x);

}
To resolve the issue you should rewrite second string with explicit cast as below

IEnumerable<double> d = a.Select(i => (double)i);

No comments:

HOWTO: Repair Logitech M325 Mouse

FixIt says that you will find single screw under CE label. It isn't always true.