CKTIS / C#
System.Collections.Generic.IReadOnlyList: practical reference
System.Collections.Generic.IReadOnlyList: practical reference: IReadOnlyList<T> exposes Count and indexed reads without mutation methods on the interface.
Version: .NET API; verified on .NET 10.0.14
Syntax
System.Collections.Generic.IReadOnlyList /* select a documented member or constructor */IReadOnlyList exposes Count and indexed reads without mutation methods on the interface.
Use it when consumers need random access but should not receive list-writing operations.
The interface does not freeze the backing object or any mutable reference objects stored as elements.
An index must be in the range zero through Count minus one; the concrete exception for an out-of-range index is defined by the implementation, not by IReadOnlyList.
The complete program actually uses System.Collections.Generic.IReadOnlyList; its exact expected stdout is b.
Examples
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;
IReadOnlyList<string> values = new[] { "a", "b" };
Console.WriteLine(values[1]);
Result
b
The complete program actually uses `System.Collections.Generic.IReadOnlyList`; its exact expected stdout is `b`.