• Advertisement
Sign in to follow this  

.NET: Serializing a list

This topic is 2111 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In C#, this code doesn't work, as the list is not serializable. What can I do to easily save "Planet" as an XML file?


[Serializable]
class Planet
{
string Name;
List<City> Cities;
}
[Serializable]
class City
{
string Name;
[...]
}


I will probably add many proprieties to both class during development and I don't want to change my serialization code every time.

Share this post


Link to post
Share on other sites
Advertisement
Sorry, my mistake. It was a simple error - my City class did not have a constructor without parameters so it didn't work...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement