1
Answer

How to join 2 dictionaries together ?

paddy

paddy

16y
16.1k
1
Hi,

how do I (aggregate ?) two dictionaries ?

I have the following code :

            private Dictionary <int, aor.PhysicalObject> agents;
            private Dictionary <int, aor.PhysicalObject> objects;

            agents = (from a in log.InitialState.Agents.Agent
                            select a).ToDictionary(d => Convert.ToInt32(d.id), d => d as aor.PhysicalObject);

            objects = (from o in log.InitialState.Objects.Object
                            select o).ToDictionary(d => Convert.ToInt32(d.id), d => d as aor.PhysicalObject);

what I want now, is ONE dictionary containing all elements of the agents & objects dictionary. You may
think that there could be a problem with duplicate keys, but each key (id) is unique, so there will be no
problem.

Would be very cool, if this task could be done via only one LINQ query (like the above... just "put together").

Many thanks in advance :-)

bye
paddy3k
Answers (1)