I don’t know how to convert the type for name so that each element in it can be added to my ListBox. If someone could help that would be much appreciated.
XDocument doc = XDocument.Load(workingDir + @"\Moduleslist.xml");
var names = doc.Root.Descendants("Module").Elements("Name").Select(b => b.Value);
listBox1.Items.AddRange(names);
I’m getting an error on AddRange(names) saying invalid arguments
names is
IEnumerable<String>andlistBox.Items.AddRangeis expecting an object array and there is no implicit cast between them.A quick solution would be to:
or