CKTIS / C#
System.Collections.Immutable.ImmutableList: praktická reference
System.Collections.Immutable.ImmutableList: praktická reference: ImmutableList<T> po změnách vrací strukturálně sdílené verze seznamu.
Verze: .NET API; verified on .NET 10.0.14
Syntaxe
System.Collections.Immutable.ImmutableList /* select a documented member or constructor */ImmutableList po změnách vrací strukturálně sdílené verze seznamu.
Použijte ji, když potřebujete operace seznamu a předchozí verze musí zůstat platné.
Náklady indexování a změn se liší od List; neměnnost ji automaticky nezrychluje.
Index mimo rozsah vyvolá výjimku a objekty použité jako prvky zůstávají měnitelné.
Úplný program skutečně používá System.Collections.Immutable.ImmutableList; přesně očekávaný stdout je 2.
Pří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;
var list = ImmutableList<int>.Empty.Add(1).Add(2);
Console.WriteLine(list[1]);
Výsledek
2
Úplný program skutečně používá `System.Collections.Immutable.ImmutableList`; přesně očekávaný stdout je `2`.