I have a method in a Windows form called Beginning that reads names from xml and displays them in a listbox. I want to move that method to a separate class that just deals with reading xml names. Here is the function I want to move into a different class
public void readNames()
{
string path = "runners.xml"; //path
XDocument xDoc = XDocument.Load(path);
foreach (XElement element in xDoc.Descendants("Name"))
{
myListBox.Items.Add(element.Value);
}
}
Is there a way to do this?
Also, how would I call it from my my Beginning form class?
Usage