Array.AsReadOnly<T> Method

Returns a read-only wrapper for the specified array.

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

public static ReadOnlyCollection<T> AsReadOnly<T>(
	T[] array

Type Parameters


The type of the elements of the array.


Type: T[]
The one-dimensional, zero-based array to wrap in a read-only ReadOnlyCollection<T> wrapper.

Return Value

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


array is null.

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.


Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions