CKTIS / C#
System.Collections.Immutable.ImmutableDictionary: praktická reference
System.Collections.Immutable.ImmutableDictionary: praktická reference: ImmutableDictionary<TKey,TValue> po každé skutečné změně vrátí novou strukturálně sdílenou mapu.
Verze: .NET API; verified on .NET 10.0.14
Syntaxe
System.Collections.Immutable.ImmutableDictionary /* select a documented member or constructor */ImmutableDictionary<TKey,TValue> po každé skutečné změně vrátí novou strukturálně sdílenou mapu.
Použijte jej pro bezpečné snímky a atomicky publikované aktualizace nahrazením reference mapy.
Add odmítne existující klíč, SetItem nahradí hodnotu a comparer zůstává součástí politiky slovníku.
Chybějící klíč přes indexer vyvolá výjimku a klíč null není povolen.
Úplný program skutečně používá System.Collections.Immutable.ImmutableDictionary; přesně očekávaný stdout je 4.
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 map = ImmutableDictionary<string, int>.Empty.Add("x", 4);
Console.WriteLine(map["x"]);
Výsledek
4
Úplný program skutečně používá `System.Collections.Immutable.ImmutableDictionary`; přesně očekávaný stdout je `4`.