0

Serialization is the process of saving the state of an object into persistant medium.
BinaryFormatter class is used for serializing and deserializing an object.

HybridDictionary is optimized for key-based item retrieval from both small and large collections.

using System.Collections;
using System.Collections.Specialized; 
using System.IO; 
using System.Runtime.Serialization.Formatters.Binary;

HybridDictionary hd; 
FileStream fs; 
BinaryFormatter bf; 

private void Form1_Load(object sender, EventArgs e)
{
hd = new HybridDictionary(); 
hd.Add("Sh", "Shalvin"); 
hd.Add("Sa", "Saji"); 

foreach (DictionaryEntry de in hd) 
listBox1.Items.Add(de.Key + " " + de.Value); 

fs = new FileStream(@"c:\Sh.data", FileMode.Create); 
bf = new BinaryFormatter(); 
bf.Serialize(fs, hd); 
fs.Close();
}
2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by belynmoon
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.