如何使用Linq创建一个Dictionary
(或者更好的是ConcurrentDictionary
)呢?
例如,如果我有以下XML:
<students>
<student name="fred" address="home" avg="70" />
<student name="wilma" address="home, HM" avg="88" />
.
. (more <student> blocks)
.
</students>
如果我想把数据加载到XDocument doc;
并且想用一个ConcurrentDictionary<string, Info>
(其中键是名称,Info
是保存地址和平均值的类。填充Info
现在不是我的问题),我该如何做呢?