METHOD

List.AsReadOnly

Returns a live read-only wrapper, not a copy of the source list.

Formal Syntax & Structure

csharp syntaxcsharp
ReadOnlyCollection<T> AsReadOnly()

Working Example

Example Snippetcsharp
using System.Collections.Generic;var list = new List<int> { 1 };var view = list.AsReadOnly();list.Add(2);System.Console.WriteLine(view.Count);
C# & .NET Reference