See the definition of System.Array class
public abstract class Array : IList, ...
Theoretically, I should be able to write this bit and be happy
int[] list = new int[] {};
IList iList = (IList)list;
I also should be able to call any method from the iList
ilist.Add(1); //exception here
My question is not why I get an exception, but rather why Array implements IList?
IList<T>
.IList
is legacy. – BoykinIList<>
interface, you can checkIsReadOnly
to see if you can sort. If you have separateIRWList<>
andIReadList<>
interfaces, what type do you make the member of your class? You can't useIRWList<>
because then it couldn't hold read-only objects, so you have to make it aIReadList<>
and then cast toIRWList
to do your sorting. See -- smelly, obfuscated casting. – Haunting