public virtual void Serialization() { var items = Enumerable.Range(0, 100).Select(_ => { var key = NextKey(); var values = Enumerable.Range(0, 100).Select(__ => NextValue()).ToArray(); return(new KeyValuePair <TKey, TValue[]>(key, values)); }).ToDictionary(kv => kv.Key, kv => kv.Value); var data0 = new MultiValueDictionary <TKey, TValue>(); foreach (var kv in items) { data0.Add(kv.Key, kv.Value); } var binaryFormatter = new BinaryFormatter(); byte[] bin; using (var buffer = new MemoryStream()) { binaryFormatter.Serialize(buffer, data0); bin = buffer.ToArray(); } MultiValueDictionary <TKey, TValue> data1; using (var buffer = new MemoryStream(bin, false)) { data1 = (MultiValueDictionary <TKey, TValue>)binaryFormatter.Deserialize(buffer); } Assert.Equal(data0, data1); Assert.Equal(data0.GetHashCode(), data1.GetHashCode()); var data2 = data0.Clone(); Assert.True(((object)data0).Equals(data2)); Assert.False(((object)data0).Equals(null)); Assert.False(((object)data0).Equals(2)); }