Export (0) Print
Expand All

ReadOnlyCollectionBase Class

Provides the abstract base class for a strongly typed non-generic read-only collection.

System.Object
  System.Collections.ReadOnlyCollectionBase
    More...

Namespace:  System.Collections
Assembly:  mscorlib (in mscorlib.dll)

[<AbstractClass>]
[<SerializableAttribute>]
[<ComVisibleAttribute(true)>]
type ReadOnlyCollectionBase =  
    class 
        interface ICollection 
        interface IEnumerable 
    end

The ReadOnlyCollectionBase type exposes the following members.

  NameDescription
Protected methodReadOnlyCollectionBaseInitializes a new instance of the ReadOnlyCollectionBase class.
Top

  NameDescription
Public propertyCountGets the number of elements contained in the ReadOnlyCollectionBase instance.
Protected propertyInnerListGets the list of elements contained in the ReadOnlyCollectionBase instance.
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetEnumeratorReturns an enumerator that iterates through the ReadOnlyCollectionBase instance.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public Extension MethodAsParallelEnables parallelization of a query. (Defined by ParallelEnumerable.)
Public Extension MethodAsQueryableConverts an IEnumerable to an IQueryable. (Defined by Queryable.)
Public Extension MethodCast(TResult)Casts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension MethodOfType(TResult)Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)
Top

  NameDescription
Explicit interface implemetationPrivate methodICollection.CopyToCopies the entire ReadOnlyCollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array.
Explicit interface implemetationPrivate propertyICollection.IsSynchronizedGets a value indicating whether access to a ReadOnlyCollectionBase object is synchronized (thread safe).
Explicit interface implemetationPrivate propertyICollection.SyncRootGets an object that can be used to synchronize access to a ReadOnlyCollectionBase object.
Top

A ReadOnlyCollectionBase instance is always read-only. See CollectionBase for a modifiable version of this class.

Notes to Implementers

This base class is provided to make it easier for implementers to create a strongly typed read-only custom collection. Implementers are encouraged to extend this base class instead of creating their own. Members of this base class are protected and are intended to be used through a derived class only.

This class makes the underlying collection available through the InnerList property, which is intended for use only by classes that are derived directly from ReadOnlyCollectionBase. The derived class must ensure that its own users cannot modify the underlying collection.

The following code example implements the ReadOnlyCollectionBase class.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

This implementation does not provide a synchronized (thread safe) wrapper for a ReadOnlyCollectionBase, but derived classes can create their own synchronized versions of the ReadOnlyCollectionBase using the SyncRoot property.

Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.

System.Object
  System.Collections.ReadOnlyCollectionBase
    System.ComponentModel.ComponentCollection
    System.Configuration.ConfigurationLocationCollection
    System.Diagnostics.ProcessModuleCollection
    System.Diagnostics.ProcessThreadCollection
    System.DirectoryServices.ActiveDirectory.ActiveDirectoryRoleCollection
    System.DirectoryServices.ActiveDirectory.AdamInstanceCollection
    System.DirectoryServices.ActiveDirectory.AdamRoleCollection
    System.DirectoryServices.ActiveDirectory.ApplicationPartitionCollection
    System.DirectoryServices.ActiveDirectory.AttributeMetadataCollection
    System.DirectoryServices.ActiveDirectory.DomainCollection
    System.DirectoryServices.ActiveDirectory.DomainControllerCollection
    System.DirectoryServices.ActiveDirectory.ForestTrustDomainInfoCollection
    System.DirectoryServices.ActiveDirectory.ForestTrustRelationshipCollisionCollection
    System.DirectoryServices.ActiveDirectory.GlobalCatalogCollection
    System.DirectoryServices.ActiveDirectory.ReadOnlyActiveDirectorySchemaClassCollection
    System.DirectoryServices.ActiveDirectory.ReadOnlyActiveDirectorySchemaPropertyCollection
    System.DirectoryServices.ActiveDirectory.ReadOnlyDirectoryServerCollection
    System.DirectoryServices.ActiveDirectory.ReadOnlySiteCollection
    System.DirectoryServices.ActiveDirectory.ReadOnlySiteLinkBridgeCollection
    System.DirectoryServices.ActiveDirectory.ReadOnlySiteLinkCollection
    System.DirectoryServices.ActiveDirectory.ReadOnlyStringCollection
    System.DirectoryServices.ActiveDirectory.ReplicationConnectionCollection
    System.DirectoryServices.ActiveDirectory.ReplicationCursorCollection
    System.DirectoryServices.ActiveDirectory.ReplicationFailureCollection
    System.DirectoryServices.ActiveDirectory.ReplicationNeighborCollection
    System.DirectoryServices.ActiveDirectory.ReplicationOperationCollection
    System.DirectoryServices.ActiveDirectory.TopLevelNameCollection
    System.DirectoryServices.ActiveDirectory.TrustRelationshipInformationCollection
    System.DirectoryServices.Protocols.PartialResultsCollection
    System.DirectoryServices.Protocols.SearchResultEntryCollection
    System.DirectoryServices.Protocols.SearchResultReferenceCollection
    System.DirectoryServices.ResultPropertyValueCollection
    System.Drawing.Design.CategoryNameCollection
    System.Drawing.Design.ToolboxItemCollection
    System.Security.AccessControl.AuthorizationRuleCollection
    System.Security.Authentication.ExtendedProtection.ServiceNameCollection
    System.Web.Management.WebBaseEventCollection
    System.Web.UI.Design.ClientScriptItemCollection
    System.Web.UI.WebControls.WebParts.CatalogPartCollection
    System.Web.UI.WebControls.WebParts.ConnectionInterfaceCollection
    System.Web.UI.WebControls.WebParts.ConsumerConnectionPointCollection
    System.Web.UI.WebControls.WebParts.EditorPartCollection
    System.Web.UI.WebControls.WebParts.ProviderConnectionPointCollection
    System.Web.UI.WebControls.WebParts.TransformerTypeCollection
    System.Web.UI.WebControls.WebParts.WebPartCollection
    System.Web.UI.WebControls.WebParts.WebPartDescriptionCollection
    System.Web.UI.WebControls.WebParts.WebPartVerbCollection
    System.Web.UI.WebControls.WebParts.WebPartZoneCollection
    System.Windows.Forms.FormCollection
    System.Windows.Forms.InputLanguageCollection
Show:
© 2014 Microsoft