陣列協方差

string[] strings = new[] {"foo", "bar"};
object[] objects = strings; // implicit conversion from string[] to object[]

此轉換不是型別安全的。以下程式碼將引發執行時異常:

string[] strings = new[] {"Foo"};
object[] objects = strings;

objects[0] = new object(); // runtime exception, object is not string
string str = strings[0];   // would have been bad if above assignment had succeeded