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) { }