I’m trying to get multiple descendants and give these values to some properties in a class. The part I cannot figure out is how can I figure out between the descendants:
var elements =
from descendant in doc.Descendants().Where(desc =>
desc.Name == "Name1" || desc.Name == "Name2" || desc.Name == "Name3")
select new AppInfo.Names
{
Name1 = //here I want to get the Name1 descendant .Value
Name2 = //here I want to get the Name2 descendant .Value
Name3 = //here I want to get the Name3 descendant .Value
};
Is it possible to do it like this? Or do I have to do a new iteration through the elements?
If AppInfo.Names is simply an array of names, try this:
EDIT:
In the case of Names being properties, you could use something like: