I wrote a method that sorts values of a ComboBox and then saves them into Xml file.
I'm very unhappy how it looks. Please feel free to take it apart and help me optimize it.
The method looks very similar to this one:
public void Save(ComboBox comboBoxItems)
{
var xmlElements = new XElement("Root");
List<string> children = new List<string> {comboBoxItems.Text};
foreach (string child in comboBoxItems.Items)
if (!children.Contains(child))
children.Add(child);
children.Sort();
foreach (var child in children)
xmlElements.Add(new XElement("Child", child));
xmlElements.Save("Output.xml");
}