|
by Paulo Morgado via Paulo Morgado : C# on 8/2/2010 12:06:26 AM
In a previous post, I went through how arrays have are covariant in relation to the type of its elements, but not safely covariant. In the following example, the second assignment is invalid at run time because, although the type of the objectArray variable is array of object, the real type of the array is array of string and an object cannot be assigned to a string. object[] objectArray = new string[] { "string 1", "string 2" };
objectArray[0] = "string 3";
objec
... [ read more ]
|
|