Array.AsReadOnly<(Of <(T>)>) Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Returns a read-only wrapper for the specified array.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)


Public Shared Function AsReadOnly(Of T) ( _
    array As T() _
) As ReadOnlyCollection(Of T)
public static ReadOnlyCollection<T> AsReadOnly<T>(
    T[] array

Type Parameters

  • T
    The type of the elements of the array.


Return Value

Type: System.Collections.ObjectModel..::.ReadOnlyCollection<(Of <(T>)>)
A read-only ReadOnlyCollection<(Of <(T>)>) wrapper for the specified array.


Exception Condition

array is nullNothingnullptra null reference (Nothing in Visual Basic).


To prevent any modifications to the array, expose the array only through this wrapper.

A collection that is read-only is simply a collection with a wrapper that prevents modifying the collection; therefore, if changes are made to the underlying collection, the read-only collection reflects those changes.

This method is an O(1) operation.

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0


Windows Phone

See Also


Array Class

System Namespace