Question: Why can't i add an Array of Integers
to a List<Object>
?
following the posts:
do-value-types-integer-decimal-boolean-etc-inherit-from-object
how-do-valuetypes-derive-from-object-referencetype-and-still-be-valuetypes
i'm understanding the following structure:
Integer => Inherits => System.ValueType => Inherits => System.Object
Then why am i getting an error when i do the following:
List<object> myObjects = new List<object>();
myObjects.AddRange(IntegerArray.ToList());
Given Error:
cannot convert from 'System.Collections.Generic.List<int>' to
'System.Collections.Generic.IEnumerable<object>
This one works though:
List<int> myObjects = new List<int>();
myObjects.AddRange(IntegerArray.ToList());