如何使用Linq 创建Dictionary(甚至更好)a ConcurrentDictionary?
例如,如果我有以下XML
<students>
<student name="fred" address="home" avg="70" />
<student name="wilma" address="home, HM" avg="88" />
.
. (more <student> blocks)
.
</students>
Run Code Online (Sandbox Code Playgroud)
加载XDocument doc;并希望填充一个ConcurrentDictionary<string, Info>(其中键是名称,并且Info是一些持有地址和平均值的类.填充Info现在不是我的关注),我该怎么做?
我有一个类似于这样的xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<data>
<resource key="123">foo</resource>
<resource key="456">bar</resource>
<resource key="789">bar</resource>
</data>
Run Code Online (Sandbox Code Playgroud)
我想把它放入一个字典(排序)作为键值对.即:123:foo,456:bar ...等
钥匙是未知的.
我怎样才能做到这一点?