public Dictionary <TKey, TValue> ReadDictionary <TKey, TValue>() where TValue : ICustomSerializable, new() { int count = ReadInt32(); if (count == -1) { return(null); } else { Dictionary <TKey, TValue> dict = new Dictionary <TKey, TValue>(count); for (int i = 0; i < count; i++) { TKey key = (TKey)this.Read(); TValue value = new TValue(); value.Deserialize(this); dict.Add(key, value); } return(dict); } }