Camillia
asked on
Why this line throws an error?
Practicing interview questions. Why does the second line throws an error? Is it because an explicit conversation is needed? I read about ValueTypes but still don't understand why it errors out..
IEnumerable<object> objects = new List<string>();
IEnumerable<ValueType> v = objects; //*** error here.
IEnumerable<object> objects = new List<string>();
IEnumerable<ValueType> v = objects; //*** error here.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, Andy
ASKER
Their question was "why is there an error when compiling the code". Looking at your explanation...it's the last one...explicit conversion is needed...correct?