I am looking forward to serialize a Dictionary in order to save some of it’s information, more precisely it’s Key and one of it’s Value, into Silverlight Isolated storage. I have read many question talking about the same subject on these boards, but none were explaining what I was trying to do, or at least not in a way I could understand. I also don’t know with what I could serialize it: XmlSerializer, JSON, etc… I am trying to perform this serialization in order to ‘save’ some of the user settings, I don’t intend to send them to a Web service or anything, it’s only use will be inside the application.
Here is the structure of my Dictionary:
static Dictionary<string, User> Mydictionary
And here is the ‘User’ class:
public class User
{
public User()
{
}
public string name;
public string age;
public string groups;
}
I would like to save the Key and the ‘groups’ Value of my object and serialize only those two informations. I was asking myself if it was even possible?
Thank you, Ephismen.
Serializin/deserializing XML with Linq is very easy, I strongly recommend you take a look at it if you don’t know it yet.
Serialization will look like this:
Deserialization:
You can find some good documentation here and some examples here.