Peter Golde recently posted about the IsReadOnly and IsFixedSize change we made to the generic collection interfaces.There are also several other discussions around the net on this topic. I thought I write up something to explain the motivation and our thinking on this.

We decided that there are really not that many fixed size data structures that are not read only. In fact, we only have one – the array. We think that having a property on a very commonly implemented interface that is useful in only one case is not the right thing to do. So we decided to remove IsFixedSize. If we see a need for this in the future, we will add an interface called something like IIndexerSettable and implement it on fixed size structures.

We also decided that arrays will return true from IsReadOnly, but will actually allow setting values using the indexer (which we are trying to fix in RTM as it does not work today). In other words, the IsFixedSize and IsReadOnly properties are now changed to IsReadOnly and “is Array”, like in the following example:
 void EitherAddOrSet(IList<int> list, int newValue){
    if(!list.IsReadOnly) list.Add(newValue);
    else if(list is int[]) list[0] = newValue;
}

… oh, the IIndexerSettable interface mentioned above would work the following (and would make the EitherAddOrSet routine more general):

void EitherAddOrSet(IList<int> list, int newValue){
    if(!list.IsReadOnly) list.Add(newValue);
    else if(list is IIndexerSettable) list[0] = newValue;
}