CollectionExtensions.AsReadOnly 方法

定義

多載

AsReadOnly<T>(IList<T>)

傳回指定清單的唯讀 ReadOnlyCollection<T> 包裝函式。

AsReadOnly<TKey,TValue>(IDictionary<TKey,TValue>)

傳回目前字典的唯讀 ReadOnlyDictionary<TKey,TValue> 包裝函式。

AsReadOnly<T>(IList<T>)

來源:
CollectionExtensions.cs
來源:
CollectionExtensions.cs
來源:
CollectionExtensions.cs

傳回指定清單的唯讀 ReadOnlyCollection<T> 包裝函式。

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static System::Collections::ObjectModel::ReadOnlyCollection<T> ^ AsReadOnly(System::Collections::Generic::IList<T> ^ list);
public static System.Collections.ObjectModel.ReadOnlyCollection<T> AsReadOnly<T> (this System.Collections.Generic.IList<T> list);
static member AsReadOnly : System.Collections.Generic.IList<'T> -> System.Collections.ObjectModel.ReadOnlyCollection<'T>
<Extension()>
Public Function AsReadOnly(Of T) (list As IList(Of T)) As ReadOnlyCollection(Of T)

類型參數

T

集合中項目的類型。

參數

list
IList<T>

要包裝的清單。

傳回

此物件作為唯讀包裝函式包住目前的 IList<T>

例外狀況

listnull

適用於

AsReadOnly<TKey,TValue>(IDictionary<TKey,TValue>)

來源:
CollectionExtensions.cs
來源:
CollectionExtensions.cs
來源:
CollectionExtensions.cs

傳回目前字典的唯讀 ReadOnlyDictionary<TKey,TValue> 包裝函式。

public:
generic <typename TKey, typename TValue>
[System::Runtime::CompilerServices::Extension]
 static System::Collections::ObjectModel::ReadOnlyDictionary<TKey, TValue> ^ AsReadOnly(System::Collections::Generic::IDictionary<TKey, TValue> ^ dictionary);
public static System.Collections.ObjectModel.ReadOnlyDictionary<TKey,TValue> AsReadOnly<TKey,TValue> (this System.Collections.Generic.IDictionary<TKey,TValue> dictionary);
static member AsReadOnly : System.Collections.Generic.IDictionary<'Key, 'Value> -> System.Collections.ObjectModel.ReadOnlyDictionary<'Key, 'Value>
<Extension()>
Public Function AsReadOnly(Of TKey, TValue) (dictionary As IDictionary(Of TKey, TValue)) As ReadOnlyDictionary(Of TKey, TValue)

類型參數

TKey

字典中索引鍵的類型。

TValue

字典中值的類型。

參數

dictionary
IDictionary<TKey,TValue>

要包裝的字典。

傳回

此物件作為唯讀包裝函式包住目前的 IDictionary<TKey,TValue>

例外狀況

dictionarynull

適用於