wafers
wafers

Reputation: 1241

C# with Linq XML

I'm a newbie, could someone please help me what type is the "Parts", I am unable to find the correct type and hence can't return the object "Parts". Thanks

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;
 }

Upvotes: 0

Views: 143

Answers (2)

Kendall Frey
Kendall Frey

Reputation: 44374

Rather than an answer that gives the information the OP is looking for, I will give an answer that shows how to find it. It is easier for all of us I think.

In Visual Studio, if you mouse-over a variable, a tooltip is displayed that includes the variable's type. This is quite useful if you are like me and dislike var, as it lets you see at a glance what the actual type is.

Upvotes: 3

Kirk Woll
Kirk Woll

Reputation: 77616

Since you're selecting a new dictSuras, the return value is an IEnumerable<dictSuras>.

Upvotes: 5

Related Questions