This looks like a plain bug to me:
- It clearly isn't read-only, as the indexer allows it to be modified
- It is not performing a conversion to any other kind of object
Note that you don't need to cast - there's an implicit conversion:
using System;
using System.Collections.Generic;
class Test
{
static void Main()
{
string[] array = new string[1];
IList list = array;
Console.WriteLine(object.ReferenceEquals(array, list));
Console.WriteLine(list.IsReadOnly);
list[0] = "foo";
Console.WriteLine(list[0]);
}
}
ICollection.IsReadOnly
(which IList
inherits the property from) is documented as:
A collection that is read-only does not allow the addition, removal, or modification of elements after the collection is created.
While an array doesn't allow the addition or removal of elements, it clearly does allow modification.