using System.Collections; namespace System.Windows.Forms { public partial class CheckedListBox { public class CheckedItemCollection : CollectionBase { private static string message = "Collection is read only."; public object this[int index] => ((Item)List[index]).Value; internal void Add(object obj) => List.Add(obj); public new void Clear() => throw new NotSupportedException(message); public new void RemoveAt(int index) => throw new NotSupportedException(message); // the reason for this method is that enumerator must return Item.Value rather than Item itself public new IEnumerator GetEnumerator() { foreach (Item item in List) yield return item.Value; } } } }