May 2010
Intermediate to advanced
1272 pages
61h 18m
English
ReadOnlyCollection(Of T) CollectionThe System.Collections.ObjectModel.ReadOnlyCollection(Of T) is the read-only counterpart of the List(Of T) class. Being read-only, you can add items to the collection only when you create an instance, but then you cannot change it. The constructor requires an argument of type IList(Of T) so that the new collection will be generated starting from an existing one. The following code demonstrates how you can instantiate a new ReadonlyCollection:

As an alternative, you can create a ReadonlyCollection invoking the List(Of T).AsReadOnly method, as shown in the following code:
'Same as above Dim readonly As ReadOnlyCollection(Of ...
Read now
Unlock full access