CKTIS / C#
System.Collections.Generic.IReadOnlyList: praktična referenca
System.Collections.Generic.IReadOnlyList: praktična referenca: IReadOnlyList<T> ponuja Count in indeksirano branje brez metod za spreminjanje na vmesniku.
Različica: .NET API; verified on .NET 10.0.14
Sintaksa
System.Collections.Generic.IReadOnlyList /* select a documented member or constructor */IReadOnlyList ponuja Count in indeksirano branje brez metod za spreminjanje na vmesniku.
Uporabite ga, ko porabnik potrebuje naključni dostop, vendar ne sme dobiti operacij za pisanje v seznam.
Vmesnik ne zamrzne osnovnega objekta ali spremenljivih referenčnih objektov, shranjenih kot elementi.
Indeks mora biti med nič in Count minus ena; konkretno izjemo za indeks zunaj območja določa izvedba, ne IReadOnlyList.
Celoten program dejansko uporabi System.Collections.Generic.IReadOnlyList; natančno pričakovani stdout je b.
Primeri
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]);
Rezultat
b
Celoten program dejansko uporabi `System.Collections.Generic.IReadOnlyList`; natančno pričakovani stdout je `b`.