相关疑难解决方法(0)

使用Linq创建一个字典

如何使用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现在不是我的关注),我该怎么做?

c# linq dictionary concurrentdictionary

4
推荐指数
1
解决办法
1477
查看次数

将xml转换为已排序的字典

我有一个类似于这样的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 ...等

钥匙是未知的.

我怎样才能做到这一点?

c# xml

2
推荐指数
3
解决办法
1万
查看次数

标签 统计

c# ×2

concurrentdictionary ×1

dictionary ×1

linq ×1

xml ×1