Start New Discussion within our Software Development Community

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:\", FileMode.Create); 
bf = new BinaryFormatter(); 
bf.Serialize(fs, hd);