Skip to content

Instantly share code, notes, and snippets.

@alanmcgovern
Created March 21, 2013 17:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanmcgovern/6b08bc8f2b15c730787b to your computer and use it in GitHub Desktop.
Save alanmcgovern/6b08bc8f2b15c730787b to your computer and use it in GitHub Desktop.
[Serializable]
public class MyDictionary<K, V> : Dictionary<K, V>
{
public MyDictionary ()
{
}
protected MyDictionary(SerializationInfo info,
StreamingContext context)
{
foreach (var v in (KeyValuePair<K, V>[]) info.GetValue ("contents", typeof (KeyValuePair<K, V>[])))
Add (v.Key, v.Value);
}
public override void GetObjectData (SerializationInfo info, StreamingContext context)
{
info.AddValue ("contents", this.ToArray ());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment