SynchronizedReadOnlyCollection<T> Class

Definition

Provides a thread-safe, read-only collection that contains objects of a type specified by the generic parameter as elements.

generic <typename T>
public ref class SynchronizedReadOnlyCollection : System::Collections::Generic::ICollection<T>, System::Collections::Generic::IEnumerable<T>, System::Collections::Generic::IList<T>, System::Collections::IList
[System.Runtime.InteropServices.ComVisible(false)]
public class SynchronizedReadOnlyCollection<T> : System.Collections.Generic.ICollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IList<T>, System.Collections.IList
type SynchronizedReadOnlyCollection<'T> = class
    interface IList<'T>
    interface ICollection<'T>
    interface seq<'T>
    interface IList
    interface ICollection
    interface IEnumerable
Public Class SynchronizedReadOnlyCollection(Of T)
Implements ICollection(Of T), IEnumerable(Of T), IList, IList(Of T)

Type Parameters

T

The type of object contained as items in the thread-safe, read-only collection.

Inheritance
SynchronizedReadOnlyCollection<T>
Attributes
Implements

Remarks

The SynchronizedReadOnlyCollection<T> stores data in an IList<T> container and provides an object that can be set and used to synchronize access to the collection so that it is thread safe. The IList<T> container can be recovered using the Items property. The synchronized object can be recovered using the ICollection.SyncRoot property. It can only be set using one of the constructors that take the syncRoot parameter.

Constructors

SynchronizedReadOnlyCollection<T>()

Initializes a new instance of the SynchronizedReadOnlyCollection<T> class.

SynchronizedReadOnlyCollection<T>(Object)

Initializes a new instance of the SynchronizedReadOnlyCollection<T> class with the object used to synchronize access to the thread-safe, read-only collection.

SynchronizedReadOnlyCollection<T>(Object, IEnumerable<T>)

Initializes a new instance of the SynchronizedReadOnlyCollection<T> class from a specified enumerable list of elements and with the object used to synchronize access to the thread-safe, read-only collection.

SynchronizedReadOnlyCollection<T>(Object, List<T>, Boolean)
SynchronizedReadOnlyCollection<T>(Object, T[])

Initializes a new instance of the SynchronizedReadOnlyCollection<T> class from a specified array of elements and with the object used to synchronize access to the thread-safe, read-only collection.

Properties

Count

Gets the number of elements contained in the thread-safe, read-only collection.

Item[Int32]

Gets an element from the thread-safe, read-only collection with a specified index.

Items

Gets the list of elements contained in the thread-safe, read-only collection.

Methods

Contains(T)

Determines whether the collection contains an element with a specific value.

CopyTo(T[], Int32)

Copies the elements of the collection to a specified array, starting at a particular index.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator()

Returns an enumerator that iterates through the synchronized, read-only collection.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
IndexOf(T)

Returns the index of the first occurrence of a value in the collection.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

ICollection.CopyTo(Array, Int32)

Copies the elements of the collection to a specified array, starting at a particular index.

ICollection.IsSynchronized

This property always returns true because the collection is thread safe.

ICollection.SyncRoot

Gets the object used to synchronize access to the thread-safe, read-only collection.

ICollection<T>.Add(T)

Throws a NotSupportedException if called.

ICollection<T>.Clear()

Throws a NotSupportedException if called.

ICollection<T>.IsReadOnly

This property always returns true because the collection is read-only.

ICollection<T>.Remove(T)

Throws a NotSupportedException in all cases.

IEnumerable.GetEnumerator()

Returns an enumerator that iterates through the synchronized, read-only collection.

IList.Add(Object)

Adds an element to the collection.

IList.Clear()

Items cannot be cleared from a read-only collection.

IList.Contains(Object)

Checks whether the specified object exists in the collection.

IList.IndexOf(Object)

Gets the index of the specified item.

IList.Insert(Int32, Object)

Items cannot be inserted into a read-only collection.

IList.IsFixedSize

This property returns true because the read-only collection is always fixed in size.

IList.IsReadOnly

This property always returns true because the collection is read-only.

IList.Item[Int32]

Gets the item at a specified zero-based index.

IList.Remove(Object)

Retrieves the specified element from the collection.

IList.RemoveAt(Int32)

Items cannot be removed from a read-only collection.

IList<T>.Insert(Int32, T)

Throws a NotSupportedException if called.

IList<T>.Item[Int32]

Returns the object in the collection that has the specified index.

IList<T>.RemoveAt(Int32)

Throws a NotSupportedException if called.

Extension Methods

CopyToDataTable<T>(IEnumerable<T>)

Returns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

Copies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

Copies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Cast<TResult>(IEnumerable)

Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

Enables parallelization of a query.

AsQueryable(IEnumerable)

Converts an IEnumerable to an IQueryable.

Ancestors<T>(IEnumerable<T>)

Returns a collection of elements that contains the ancestors of every node in the source collection.

Ancestors<T>(IEnumerable<T>, XName)

Returns a filtered collection of elements that contains the ancestors of every node in the source collection. Only elements that have a matching XName are included in the collection.

DescendantNodes<T>(IEnumerable<T>)

Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>)

Returns a collection of elements that contains the descendant elements of every element and document in the source collection.

Descendants<T>(IEnumerable<T>, XName)

Returns a filtered collection of elements that contains the descendant elements of every element and document in the source collection. Only elements that have a matching XName are included in the collection.

Elements<T>(IEnumerable<T>)

Returns a collection of the child elements of every element and document in the source collection.

Elements<T>(IEnumerable<T>, XName)

Returns a filtered collection of the child elements of every element and document in the source collection. Only elements that have a matching XName are included in the collection.

InDocumentOrder<T>(IEnumerable<T>)

Returns a collection of nodes that contains all nodes in the source collection, sorted in document order.

Nodes<T>(IEnumerable<T>)

Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>)

Removes every node in the source collection from its parent node.

Applies to