Wie kann ich eine neue Instanz von Immutabledictionary erstellen?C#

Ein Treffpunkt für C#-Programmierer
Guest
 Wie kann ich eine neue Instanz von Immutabledictionary erstellen?

Post by Guest »

Ich möchte so etwas schreiben: < /p>

Code: Select all

var d = new ImmutableDictionary { { "a", 1 }, { "b", 2 } };
< /code>

(mithilfe von ImmutableDictionary < /code> von System.collections.immable). Es scheint eine einfache Verwendung zu sein, da ich alle Werte im Voraus deklariere - keine Mutation dort. Dies gibt mir jedoch einen Fehler: < /p>


Der Typ 'System.Collections.Immutable.ImmutableDictionary
'hat keine Konstruktoren definiert


Wie soll ich ein neues unveränderliches Wörterbuch mit statischer Inhalt erstellen?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post