CollectionExtensions.AsReadOnly Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
AsReadOnly<T>(IList<T>) |
Returns a read-only ReadOnlyCollection<T> wrapper for the specified list. |
AsReadOnly<T>(ISet<T>) | |
AsReadOnly<TKey,TValue>(IDictionary<TKey,TValue>) |
Returns a read-only ReadOnlyDictionary<TKey,TValue> wrapper for the current dictionary. |
- Source:
- CollectionExtensions.cs
- Source:
- CollectionExtensions.cs
- Source:
- CollectionExtensions.cs
Returns a read-only ReadOnlyCollection<T> wrapper for the specified list.
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)
Type Parameters
- T
The type of elements in the collection.
Parameters
- list
- IList<T>
The list to wrap.
Returns
An object that acts as a read-only wrapper around the current IList<T>.
Exceptions
list
is null
.
Applies to
.NET 10 та інші версії
Продукт | Версії |
---|---|
.NET | 7, 8, 9, 10 |
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)
Type Parameters
- T
Parameters
- set
- ISet<T>
Returns
Applies to
.NET 10
Продукт | Версії |
---|---|
.NET | 10 |
- Source:
- CollectionExtensions.cs
- Source:
- CollectionExtensions.cs
- Source:
- CollectionExtensions.cs
Returns a read-only ReadOnlyDictionary<TKey,TValue> wrapper for the current dictionary.
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)
Type Parameters
- TKey
The type of keys in the dictionary.
- TValue
The type of values in the dictionary.
Parameters
- dictionary
- IDictionary<TKey,TValue>
The dictionary to wrap.
Returns
An object that acts as a read-only wrapper around the current IDictionary<TKey,TValue>.
Exceptions
dictionary
is null
.
Applies to
.NET 10 та інші версії
Продукт | Версії |
---|---|
.NET | 7, 8, 9, 10 |
Відгук про .NET
.NET – це проект із відкритим кодом. Виберіть посилання, щоб надати відгук: