CollectionExtensions.AsReadOnly Method
Definition
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.
Overloads
| Name | Description |
|---|---|
|
AsReadOnly |
Returns a read-only ReadOnlyCollection |
|
AsReadOnly |
Returns a read-only ReadOnlySet |
|
AsReadOnly |
Returns a read-only ReadOnlyDictionary |
AsReadOnly(IList)
- Source:
- CollectionExtensions.cs
- Source:
- CollectionExtensions.cs
- Source:
- CollectionExtensions.cs
- Source:
- CollectionExtensions.cs
- Source:
- CollectionExtensions.cs
Returns a read-only ReadOnlyCollection
public:
generic
[System::Runtime::CompilerServices::Extension]
static System::Collections::ObjectModel::ReadOnlyCollection ^ AsReadOnly(System::Collections::Generic::IList ^ list);
public static System.Collections.ObjectModel.ReadOnlyCollection AsReadOnly(this System.Collections.Generic.IList list);
static member AsReadOnly : System.Collections.Generic.IList<'T> -> System.Collections.ObjectModel.ReadOnlyCollection<'T>
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
The list to wrap.
Returns
An object that acts as a read-only wrapper around the current IList
Exceptions
list is null.
Applies to
AsReadOnly(ISet)
- Source:
- CollectionExtensions.cs
- Source:
- CollectionExtensions.cs
Returns a read-only ReadOnlySet
public:
generic
[System::Runtime::CompilerServices::Extension]
static System::Collections::ObjectModel::ReadOnlySet ^ AsReadOnly(System::Collections::Generic::ISet ^ set);
public static System.Collections.ObjectModel.ReadOnlySet AsReadOnly(this System.Collections.Generic.ISet set);
static member AsReadOnly : System.Collections.Generic.ISet<'T> -> System.Collections.ObjectModel.ReadOnlySet<'T>
Public Function AsReadOnly(Of T) (set As ISet(Of T)) As ReadOnlySet(Of T)
Type Parameters
- T
The type of elements in the set.
Parameters
- set
-
ISet
The set to wrap.
Returns
An object that acts as a read-only wrapper around the current ISet
Exceptions
set is null.
Applies to
AsReadOnly(IDictionary)
- Source:
- CollectionExtensions.cs
- Source:
- CollectionExtensions.cs
- Source:
- CollectionExtensions.cs
- Source:
- CollectionExtensions.cs
- Source:
- CollectionExtensions.cs
Returns a read-only ReadOnlyDictionary
public:
generic
[System::Runtime::CompilerServices::Extension]
static System::Collections::ObjectModel::ReadOnlyDictionary ^ AsReadOnly(System::Collections::Generic::IDictionary ^ dictionary);
public static System.Collections.ObjectModel.ReadOnlyDictionary AsReadOnly(this System.Collections.Generic.IDictionary dictionary);
static member AsReadOnly : System.Collections.Generic.IDictionary<'Key, 'Value> -> System.Collections.ObjectModel.ReadOnlyDictionary<'Key, 'Value>
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
The dictionary to wrap.
Returns
An object that acts as a read-only wrapper around the current IDictionary
Exceptions
dictionary is null.