使用xdocument排序后访问该值

时间:2015-07-16 12:41:51

标签: c# asp.net-mvc

以下是代码:

GroupName

现在我想访问statusout并希望将其存储在datetime变量中? 有什么建议吗?

1 个答案:

答案 0 :(得分:0)

匿名类型没有(程序员可访问的)typename。

所以你需要定义一个。或者使用框架中的内容:

void GetData(out Tuple<string, string> extracted) {
  extracted = null;

  // ...

  extracted = xDoc.Root.Elements()
                  .OrderBy(x => (string)x.Attribute("name"))
                  .Select(n => Tuple.Create(
                                       n.Attribute("name").Value, 
                                       n.Element("Status").Value
                  ));
               );
}