<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.0" />

SettingsPropertyValueCollection

Contains a collection of settings property values that map SettingsProperty objects to SettingsPropertyValue objects.
using System.Collections; namespace System.Configuration { public class SettingsPropertyValueCollection : IEnumerable, ICloneable, ICollection { private readonly Hashtable _indices; private ArrayList _values; private bool _readOnly; public SettingsPropertyValue this[string name] { get { object obj = _indices[name]; if (obj == null || !(obj is int)) return null; int num = (int)obj; if (num >= _values.Count) return null; return (SettingsPropertyValue)_values[num]; } } public int Count => _values.Count; public bool IsSynchronized => false; public object SyncRoot => this; public SettingsPropertyValueCollection() { _indices = new Hashtable(10, StringComparer.CurrentCultureIgnoreCase); _values = new ArrayList(); } public void Add(SettingsPropertyValue property) { if (_readOnly) throw new NotSupportedException(); int num = _values.Add(property); try { _indices.Add(property.Name, num); } catch (Exception) { _values.RemoveAt(num); throw; } } public void Remove(string name) { if (_readOnly) throw new NotSupportedException(); object obj = _indices[name]; if (obj != null && obj is int) { int num = (int)obj; if (num < _values.Count) { _values.RemoveAt(num); _indices.Remove(name); ArrayList arrayList = new ArrayList(); IDictionaryEnumerator enumerator = _indices.GetEnumerator(); try { while (enumerator.MoveNext()) { DictionaryEntry dictionaryEntry = (DictionaryEntry)enumerator.Current; if ((int)dictionaryEntry.Value > num) arrayList.Add(dictionaryEntry.Key); } } finally { (enumerator as IDisposable)?.Dispose(); } foreach (string item in arrayList) { _indices[item] = (int)_indices[item] - 1; } } } } public IEnumerator GetEnumerator() { return _values.GetEnumerator(); } public object Clone() { return new SettingsPropertyValueCollection(_indices, _values); } public void SetReadOnly() { if (!_readOnly) { _readOnly = true; _values = ArrayList.ReadOnly(_values); } } public void Clear() { _values.Clear(); _indices.Clear(); } public void CopyTo(Array array, int index) { _values.CopyTo(array, index); } private SettingsPropertyValueCollection(Hashtable indices, ArrayList values) { _indices = (Hashtable)indices.Clone(); _values = (ArrayList)values.Clone(); } } }