The following code gives an InvalidCast
Exception
int newValue = new List<decimal>() { 6m }.Cast<int>().FirstOrDefault();
Even though decimal
can be casted int
, why can it not be done in a list?
Edit:
To clear up the question, I want to know why the cast part of the equation throws an exception. Just running new List<decimal>() { 6m }.Cast<int>().ToList()
Would also give an InvalidCast
Exception