arraylist.readonly equivalent.

  • Thread starter Thread starter Ashish
  • Start date Start date
A

Ashish

hi all,


Iam trying to create my own collection, on the lines of Arratlist, and
iam trying to implement something like ArrayList.Readonly ,return a
readonly version of the same collection ...

any thoughts ?

TIA
 
Create a class that inherits from System.Collections.CollectionBase,
implement the standard methods (i.e. Add, Insert, Remove, Item, etc), add a
boolean IsReadOnly property, then in any method or property that would
modify the internal List throw an exception if the IsReadOnly property is
true.
 
Thanks Rob,

I was also wondering as to why am i not able to implement a function
named ReadOnly(list Ilist) , that returns IList, but Arraylist has that
implementation ? ( it complains of ReadOnly being a reserved word...)

regards
 
If you want to use a reserved word for the name of a member just surround it
with square brackets. For example:

Public Sub [ReadOnly](ByVal list As IList)
 
Back
Top