CollectionExtensions.AsReadOnly 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| AsReadOnly<T>(IList<T>) |
回傳指定清單的唯讀 ReadOnlyCollection<T> 包裝器。 |
| AsReadOnly<T>(ISet<T>) |
回傳指定集合的唯讀 ReadOnlySet<T> 包裝器。 |
| AsReadOnly<TKey,TValue>(IDictionary<TKey,TValue>) |
回傳一個唯讀 ReadOnlyDictionary<TKey,TValue> 包裝器,針對目前字典。 |
AsReadOnly<T>(IList<T>)
回傳指定清單的唯讀 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>的物件。
例外狀況
list 是 null。
適用於
AsReadOnly<T>(ISet<T>)
回傳指定集合的唯讀 ReadOnlySet<T> 包裝器。
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static System::Collections::ObjectModel::ReadOnlySet<T> ^ AsReadOnly(System::Collections::Generic::ISet<T> ^ set);
public static System.Collections.ObjectModel.ReadOnlySet<T> AsReadOnly<T>(this System.Collections.Generic.ISet<T> set);
static member AsReadOnly : System.Collections.Generic.ISet<'T> -> System.Collections.ObjectModel.ReadOnlySet<'T>
<Extension()>
Public Function AsReadOnly(Of T) (set As ISet(Of T)) As ReadOnlySet(Of T)
類型參數
- T
集合中的項目類型。
參數
- set
- ISet<T>
要收尾的演出。
傳回
一個作為只讀包裝器,包覆當前 ISet<T>的物件。
例外狀況
set 是 null。
適用於
AsReadOnly<TKey,TValue>(IDictionary<TKey,TValue>)
回傳一個唯讀 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>的物件。
例外狀況
dictionary 是 null。