CKTIS / C#
System.Collections.Frozen.FrozenDictionary: referencia práctica
System.Collections.Frozen.FrozenDictionary: referencia práctica: FrozenDictionary<TKey,TValue> es un índice inmutable preparado una vez para búsquedas rápidas y frecuentes por clave.
Versión: .NET 8+; verified on .NET 10.0.14
Sintaxis
System.Collections.Frozen.FrozenDictionary /* select a documented member or constructor */FrozenDictionary<TKey,TValue> es un índice inmutable preparado una vez para búsquedas rápidas y frecuentes por clave.
Créalo para datos duraderos de configuración o consulta que se lean mucho más a menudo de lo que cambian.
La construcción tiene un coste y fija el comparador, por lo que no conviene para datos que se reconstruyen con frecuencia.
Las claves duplicadas fallan durante la construcción y los cambios posteriores del origen no modifican el diccionario congelado.
El programa completo usa realmente System.Collections.Frozen.FrozenDictionary; su stdout esperado exacto es 1.
Ejemplos
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 = new Dictionary<string, int> { ["a"] = 1 }.ToFrozenDictionary();
Console.WriteLine(map["a"]);
Resultado
1
El programa completo usa realmente `System.Collections.Frozen.FrozenDictionary`; su stdout esperado exacto es `1`.