Collection

  • Thread starter Thread starter Guest
  • Start date Start date
Hi wansch,

I don't know what do you mean by 'external users', but ArrayList has static
method ReadOnly that returns readonly wrapper around the array lists or
objects that expose IList interface.

If you want strongly type collections you can inherit form
ReadOnlyCollectionBase and create your own. You may have for example
internal methods for modifying the collections and public methods for
accessing elements in a readonly manner.
 
I don't think you can, quite.

As a work-around, create your own class that implements IList, contains a
private collection, and which for the readonly Item() property, returns not
an element from the collection, but a clone of it.

That way, at least any changes made will be changes to the (discarded)
clone, and not to the actual elements in the collection.
 
I don't think you can, quite.

As a work-around, create your own class that implements IList, contains a
private collection, and which for the readonly Item() property, returns not
an element from the collection, but a clone of it.

That way, at least any changes made will be changes to the (discarded)
clone, and not to the actual elements in the collection.
 
Back
Top