Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • C#
using System.Collections.Generic;
var x = new Dictionary<string, int> {
   ["year"] = 2019,
   ["month"] = 12
};
using System.Collections.Generic;
var x = new Dictionary<string, int> {
   {"year", 2019}, {"month", 12}
};

Example uses collection initializer. To add manually, use:

x.Add(1, "Value1");
with Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Strings.Hash;

use Ada.Containers;
declare
   package Maps is new Indefinite_Hashed_Maps (Key_Type => String,
                                               Element_Type => Integer,
                                               Hash => Ada.Strings.Hash,
                                               Equivalent_Keys => "=");
      
   use Maps;
      
   X : Map := Empty_Map;
begin
   X.Insert ("One", 1);
   X.Insert ("Two", 2);
   X.Insert ("Three", 3);
end;

New implementation...