SynchronizedReadOnlyCollection<T> SynchronizedReadOnlyCollection<T> SynchronizedReadOnlyCollection<T> SynchronizedReadOnlyCollection<T> Class

定義

提供具備執行緒安全的唯讀集合,其中包含由泛型參數指定做為項目之型別的物件。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)

類型參數

T

包含在具備執行緒安全的唯讀集合中做為項目的物件型別。The type of object contained as items in the thread-safe, read-only collection.

繼承
SynchronizedReadOnlyCollection<T>SynchronizedReadOnlyCollection<T>SynchronizedReadOnlyCollection<T>SynchronizedReadOnlyCollection<T>
屬性
實作

備註

SynchronizedReadOnlyCollection<T> 會將資料儲存在 IList<T> 容器中,並提供可設定及用來同步處理集合之存取的物件,使其具備執行緒安全。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. 若使用 IList<T> 屬性,則可以復原 Items 容器。The IList<T> container can be recovered using the Items property. 若使用 ICollection.SyncRoot 屬性,則可以復原同步處理的物件。The synchronized object can be recovered using the ICollection.SyncRoot property. 它只能使用其中一個採用 syncRoot 參數的建構函式來設定。It can only be set using one of the constructors that take the syncRoot parameter.

建構函式

SynchronizedReadOnlyCollection<T>() SynchronizedReadOnlyCollection<T>() SynchronizedReadOnlyCollection<T>() SynchronizedReadOnlyCollection<T>()

初始化 SynchronizedReadOnlyCollection<T> 類別的新執行個體。Initializes a new instance of the SynchronizedReadOnlyCollection<T> class.

SynchronizedReadOnlyCollection<T>(Object) SynchronizedReadOnlyCollection<T>(Object) SynchronizedReadOnlyCollection<T>(Object) SynchronizedReadOnlyCollection<T>(Object)

使用用來同步處理存取具備執行緒安全之唯讀集合的物件,初始化 SynchronizedReadOnlyCollection<T> 類別的新執行個體。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>) SynchronizedReadOnlyCollection<T>(Object, IEnumerable<T>) SynchronizedReadOnlyCollection<T>(Object, IEnumerable<T>) SynchronizedReadOnlyCollection<T>(Object, IEnumerable<T>)

使用用來同步處理存取具備執行緒安全之唯讀集合的物件,從指定的可列舉項目清單初始化 SynchronizedReadOnlyCollection<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, List<T>, Boolean) SynchronizedReadOnlyCollection<T>(Object, List<T>, Boolean) SynchronizedReadOnlyCollection<T>(Object, List<T>, Boolean)
SynchronizedReadOnlyCollection<T>(Object, T[]) SynchronizedReadOnlyCollection<T>(Object, T[]) SynchronizedReadOnlyCollection<T>(Object, T[]) SynchronizedReadOnlyCollection<T>(Object, T[])

使用用來同步處理存取具備執行緒安全之唯讀集合的物件,從指定的項目陣列初始化 SynchronizedReadOnlyCollection<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.

屬性

Count Count Count Count

取得具備執行緒安全之唯讀集合中所含的項目數目。Gets the number of elements contained in the thread-safe, read-only collection.

Items Items Items Items

取得包含在具備執行緒安全之唯讀集合中的項目清單。Gets the list of elements contained in the thread-safe, read-only collection.

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

從具有指定索引且具備執行緒安全的唯讀集合中取得項目。Gets an element from the thread-safe, read-only collection with a specified index.

方法

Contains(T) Contains(T) Contains(T) Contains(T)

判斷集合是否包含具有特定值的項目。Determines whether the collection contains an element with a specific value.

CopyTo(T[], Int32) CopyTo(T[], Int32) CopyTo(T[], Int32) CopyTo(T[], Int32)

從特定索引開始,將集合的項目複製到指定的陣列。Copies the elements of the collection to a specified array, starting at a particular index.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

傳回逐一查看經過同步處理之唯讀集合的列舉值。Returns an enumerator that iterates through the synchronized, read-only collection.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
IndexOf(T) IndexOf(T) IndexOf(T) IndexOf(T)

傳回集合中第一個出現之值的索引。Returns the index of the first occurrence of a value in the collection.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

明確介面實作

ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32)

從特定索引開始,將集合的項目複製到指定的陣列。Copies the elements of the collection to a specified array, starting at a particular index.

ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized

這個屬性一律會傳回 true,因為該集合具備執行緒安全。This property always returns true because the collection is thread safe.

ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot

取得用來同步處理存取具備安全執行緒之唯讀集合的物件。Gets the object used to synchronize access to the thread-safe, read-only collection.

ICollection<T>.Add(T) ICollection<T>.Add(T) ICollection<T>.Add(T) ICollection<T>.Add(T)

如果呼叫,則會擲回 NotSupportedExceptionThrows a NotSupportedException if called.

ICollection<T>.Clear() ICollection<T>.Clear() ICollection<T>.Clear() ICollection<T>.Clear()

如果呼叫,則會擲回 NotSupportedExceptionThrows a NotSupportedException if called.

ICollection<T>.IsReadOnly ICollection<T>.IsReadOnly ICollection<T>.IsReadOnly ICollection<T>.IsReadOnly

這個屬性一律會傳回 true,因為該集合為唯讀。This property always returns true because the collection is read-only.

ICollection<T>.Remove(T) ICollection<T>.Remove(T) ICollection<T>.Remove(T) ICollection<T>.Remove(T)

在所有情況下都擲回 NotSupportedExceptionThrows a NotSupportedException in all cases.

IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

傳回逐一查看經過同步處理之唯讀集合的列舉值。Returns an enumerator that iterates through the synchronized, read-only collection.

IList.Add(Object) IList.Add(Object) IList.Add(Object) IList.Add(Object)

新增項目至集合。Adds an element to the collection.

IList.Clear() IList.Clear() IList.Clear() IList.Clear()

這些項目無法從唯讀的集合中清除。Items cannot be cleared from a read-only collection.

IList.Contains(Object) IList.Contains(Object) IList.Contains(Object) IList.Contains(Object)

檢查指定的物件是否存在集合中。Checks whether the specified object exists in the collection.

IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object)

取得指定之項目的索引。Gets the index of the specified item.

IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object)

這些項目無法插入至唯讀的集合中。Items cannot be inserted into a read-only collection.

IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize

這個屬性會傳回 true,因為該唯讀集合的大小一律固定。This property returns true because the read-only collection is always fixed in size.

IList.IsReadOnly IList.IsReadOnly IList.IsReadOnly IList.IsReadOnly

這個屬性一律會傳回 true,因為該集合為唯讀。This property always returns true because the collection is read-only.

IList.Item[Int32] IList.Item[Int32] IList.Item[Int32] IList.Item[Int32]

取得位於指定之以零起始的索引。Gets the item at a specified zero-based index.

IList.Remove(Object) IList.Remove(Object) IList.Remove(Object) IList.Remove(Object)

從集合中擷取指定的項目。Retrieves the specified element from the collection.

IList.RemoveAt(Int32) IList.RemoveAt(Int32) IList.RemoveAt(Int32) IList.RemoveAt(Int32)

這些項目無法從唯讀的集合中移除。Items cannot be removed from a read-only collection.

IList<T>.Insert(Int32, T) IList<T>.Insert(Int32, T) IList<T>.Insert(Int32, T) IList<T>.Insert(Int32, T)

如果呼叫,則會擲回 NotSupportedExceptionThrows a NotSupportedException if called.

IList<T>.Item[Int32] IList<T>.Item[Int32] IList<T>.Item[Int32] IList<T>.Item[Int32]

傳回集合中的物件,這個集合具有指定的 indexReturns the object in the collection that has the specified index.

IList<T>.RemoveAt(Int32) IList<T>.RemoveAt(Int32) IList<T>.RemoveAt(Int32) IList<T>.RemoveAt(Int32)

如果呼叫,則會擲回 NotSupportedExceptionThrows a NotSupportedException if called.

Extension Methods

CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>)

傳回DataTable,其中包含副本DataRow物件,指定輸入IEnumerable<T>物件其中泛型參數TDataRowReturns 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) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

複本DataRow至指定的物件DataTable,根據輸入IEnumerable<T>物件其中泛型參數TDataRowCopies 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) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

複本DataRow至指定的物件DataTable,根據輸入IEnumerable<T>物件其中泛型參數TDataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

將轉換IEnumerableIQueryableConverts an IEnumerable to an IQueryable.

Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) 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) Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName)

傳回包含來源集合中每個節點祖系的已篩選項目集合。Returns a filtered collection of elements that contains the ancestors of every node in the source collection. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>)

傳回來源集合中每個文件和項目之子代節點的集合。Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) 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) Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName) 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. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>) 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) Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName)

傳回來源集合中每個項目和文件的已篩選子項目集合。Returns a filtered collection of the child elements of every element and document in the source collection. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>) 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>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>)

傳回來源集合中每個文件和項目的子節點集合。Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>)

在來源集合中,從每一個節點的父節點移除這些節點。Removes every node in the source collection from its parent node.

適用於