C#with Linq XML

waf*_*ers 0 c# xml linq linq-to-xml

我是新手,有人可以请帮助我什么类型的"零件",我无法找到正确的类型,因此无法返回对象"零件".谢谢

private ???? load_parts()
{
     var element = XElement.Load("xml/suras.xml");
     **var** Parts= from var in element.Descendants("part")
                 orderby var.Attribute("index").Value
                 select new  dictSuras
                 {
                     PartIndex = Convert.ToInt32(var.Attribute("index").Value),
                     PartPosition = Convert.ToInt32(var.Attribute("position").Value),
                     PartName = var.Attribute("name").Value
                 };

     return  Parts;
 }
Run Code Online (Sandbox Code Playgroud)

Kir*_*oll 5

由于您选择了a new dictSuras,因此返回值为IEnumerable<dictSuras>.