0

I have contents in a Dictionary<string, List<string>> that I want to dump to file and then read it later and load the file contents to a dictionary in the same format, is it possible to do it in C# in an easy way?

I know I can parse the lines in the file and create back the dictionary but I was looking for something similar to the way this can be done in Python using cPickle. cPickle can dump an object to a file in binary format and then load it later from that file.

praveen
  • 3,193
  • 2
  • 26
  • 30
  • 3
    This question is too broad. The term you might find interesting is "serialization". – BartoszKP Jun 20 '14 at 17:08
  • Use XML-Serialiazation http://stackoverflow.com/questions/1799767/easy-way-to-convert-a-dictionarystring-string-to-xml-and-visa-versa?lq=1 – adjan Jun 20 '14 at 17:11
  • How do you say its to broad? I specifically asked how to serialize and deserialize a dictinary in C#. – praveen Jun 20 '14 at 17:12
  • 1
    @praveen That's not specific enough, sorry (please don't interpret the linked duplicate question as a current acceptable standard for questions - it isn't anymore). – BartoszKP Jun 20 '14 at 17:12
  • @BartoszKP care to explain what could be specific here? – praveen Jun 20 '14 at 17:15
  • @praveen You should first try some tutorials/documentation/google and experiments with code. Usually this is enough to solve such problems (it is a very basic problem). If you should encounter some problems you don't understand in your code, you can search for the answer on SO (or google in general), because most of the time you're not the first one with this problem. Only after you can't find the answer, you can describe your problem in a detailed way (i.e. with a code example demonstrating the issue), explaining what have you done so far to solve it, and how it isn't working. – BartoszKP Jun 20 '14 at 17:20
  • 1
    @BartoszKP thanks! I dont want to be rude but XmlSerializer is not what I was looking/expecting for the answer of this question. I do know how to google and look for existing solutions on SO – praveen Jun 20 '14 at 17:35
  • @praveen I didn't link to XML serialization. But from this, there is only one step to serialization in general. Read about serialization in C# (on SO, google, or MSDN) to find about other possible serializers (including binary). – BartoszKP Jun 20 '14 at 17:58

0 Answers0