I have a list that has been De-serialized from an XML file in to.
XmlRootAttribute Root = new XmlRootAttribute();
Root.ElementName = "PersonList";
List<Person> persons;
using (var reader = new StreamReader("Test.xml"))
{
XmlSerializer deserializer = new
XmlSerializer(typeof(List<Person>),Root);
persons = (List<Person>)deserializer.Deserialize(reader);
}
My XML file
<PersonList>
<Person xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ID>4</ID>
<Name>dasdas</Name>
<Address>asdasd</Address>
<Number>40</Number>
</Person>
</PersonList>
I want to group by each ID, so get all of the results if ID = '4' then add that to a PersonsID4 List or if ID = '5' add to PersonsID5 List
var test = persons.GroupBy(u => u.ID).Select(p => p.ToList()).ToList();
personslist4 = test;
If question has been asked, please direct.