我必须汇总两个字典。
代码:
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);
我现在想要的是一本包含代理和对象字典所有元素的字典。
您可能认为重复键可能有问题,但每个键(id)都是唯一的,所以不会有问题。
如果这项任务只能通过一个 LINQ 查询来完成,那就太酷了。