CKTIS / C#
System.Collections.Generic.IReadOnlyList: praktická referencia
System.Collections.Generic.IReadOnlyList: praktická referencia: IReadOnlyList<T> sprístupňuje Count a indexované čítanie bez mutačných metód na rozhraní.
Verzia: .NET API; verified on .NET 10.0.14
Syntax
System.Collections.Generic.IReadOnlyList /* select a documented member or constructor */IReadOnlyList sprístupňuje Count a indexované čítanie bez mutačných metód na rozhraní.
Použite ho, keď spotrebiteľ potrebuje náhodný prístup, ale nemá dostať operácie zápisu do zoznamu.
Rozhranie nezmrazí podkladový objekt ani meniteľné referenčné objekty uložené ako prvky.
Index musí byť v rozsahu nula až Count mínus jedna; konkrétnu výnimku pre index mimo rozsahu určuje implementácia, nie IReadOnlyList.
Úplný program skutočne používa System.Collections.Generic.IReadOnlyList; presne očakávaný stdout je b.
Príklady
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]);
Výsledok
b
Úplný program skutočne používa `System.Collections.Generic.IReadOnlyList`; presne očakávaný stdout je `b`.