using System; using System.Collections; using System.Collections.Generic; class Program { public static void Main () { SerializeDictionary (new SerializerLazyDictionary ()); } static void SerializeDictionary (IDictionary values) { } static void SerializeDictionary (IDictionary values) { } } sealed class SerializerLazyDictionary : LazyDictionary { protected override IEnumerator> GetEnumerator () { return null; } } internal abstract class LazyDictionary : IDictionary { void IDictionary.Add (string key, object value) { throw new NotSupportedException (); } bool IDictionary.ContainsKey (string key) { throw new NotSupportedException (); } ICollection IDictionary.Keys { get { throw new NotSupportedException (); } } bool IDictionary.Remove (string key) { throw new NotSupportedException (); } bool IDictionary.TryGetValue (string key, out object value) { throw new NotSupportedException (); } ICollection IDictionary.Values { get { throw new NotSupportedException (); } } object IDictionary.this [string key] { get { throw new NotSupportedException (); } set { throw new NotSupportedException (); } } void ICollection>.Add (KeyValuePair item) { throw new NotSupportedException (); } void ICollection>.Clear () { throw new NotSupportedException (); } bool ICollection>.Contains (KeyValuePair item) { throw new NotSupportedException (); } void ICollection>.CopyTo (KeyValuePair [] array, int arrayIndex) { throw new NotSupportedException (); } int ICollection>.Count { get { throw new NotSupportedException (); } } bool ICollection>.IsReadOnly { get { throw new NotSupportedException (); } } bool ICollection>.Remove (KeyValuePair item) { throw new NotSupportedException (); } IEnumerator> IEnumerable>.GetEnumerator () { return GetEnumerator (); } protected abstract IEnumerator> GetEnumerator (); System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator () { return ((IEnumerable>) this).GetEnumerator (); } }