digitalmars.D.learn - Generic container
- lurker (8/8) May 08 2010 Hello, first time visiting the newsgroup.
- wrzosk (3/11) May 08 2010 Object[string] foo;
- bearophile (4/6) May 08 2010 In D there is no the automatic boxing present in C#, so that can contain...
Hello, first time visiting the newsgroup. I see in the manual that you can create built-in dictionaries like so: int[string] foo; something like this: Dictionary<string, object> foo; I need a dictionary that can store any value, indexed by string. Thanks
May 08 2010
On 08.05.2010 23:52, lurker wrote:Hello, first time visiting the newsgroup. I see in the manual that you can create built-in dictionaries like so: int[string] foo; something like this: Dictionary<string, object> foo; I need a dictionary that can store any value, indexed by string. ThanksObject[string] foo; foo["aaa"] = new AAA();
May 08 2010
wrzosk:Object[string] foo; foo["aaa"] = new AAA();object, but not any value. If you want to store any value, you need the values of that associative array to be of some kind of Box or Variant, etc. There are variant-like types both in Phobos and Tango, but you have to test if they work well for your purposes because it seems it's easy to put bugs in a Variant implementation. Bye, bearophile
May 08 2010