Yes Dorothy, the .NET System.Array Class can throw you a NotSupportedException
Posted by jpluimers on 2016/09/21
It’s been in the System.Array class forever, but remarkably few people do know that it can throw you a NotSupportedException (for instance when calling Add, Insert, Remove, etc).
It does because it implements IList, but not all methods implemented from IList are valid.
And it also indicates that, as the IList Properties allows for IsFixedSize to return false.
A similar case is there for IsReadOnly: then you cannot even modify the values.
Ever since I started teaching .NET/C# classes almost 15 years ago, I warned:
beware when you use IList as not everybody implements all methods.
–jeroen
via:
Leave a Reply