1

I am trying to do Serialization and Deserialization for Dictionaries in C#. Problem is that, when i do Deserialization, it take 3-4 mins. Size of Text file is 4.3 MB Here is my Code .. Please help me out.

[Serializable] public class WordTag { public String Word, Tag; public double prob; public WordTag() { } public WordTag(String W, String T) { Word = W; Tag = T; } [Serializable] public class EqualityComparer : IEqualityComparer<WordTag> { public bool Equals(WordTag x, WordTag y) { return x.Word == y.Word && x.Tag == y.Tag; } public int GetHashCode(WordTag x) { return base.GetHashCode(); } } } 

.....................

 try { using (Stream stream = File.Open("e:\\WordTagFreq.txt", FileMode.Open)) { BinaryFormatter bin = new BinaryFormatter(); WordTagDic.Clear(); WordTagDic = (Dictionary<WordTag, int>)bin.Deserialize(stream); } } catch (IOException) { } 
3
  • Looks like it would be much easier and faster to do it without serialization. Commented Dec 19, 2013 at 7:17
  • You must locate where is the delay. 1) on your actions ? 2) on the big data file that need deserialize... on the second case, use a different library, for example look at protobuf-net: code.google.com/p/protobuf-net Commented Dec 19, 2013 at 7:22
  • Does this answer your question? Fastest way to serialize and deserialize .NET objects Commented Sep 29, 2022 at 16:36

1 Answer 1

2

Same question is already answered.

Fastest way to serialize and deserialize .NET objects

for further information http://www.codeproject.com/Articles/37609/Serialize-and-Deserialize-Objects-as-XML-using-Gen

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.