System.Configuration.SettingsPropertyValueCollection.Remove C# (CSharp) Method

Remove() public method

public Remove ( string name ) : void
name string
return void
        public void Remove(string name)
        {
            if (_ReadOnly)
                throw new NotSupportedException();

            object pos = _Indices[name];

            if (pos == null || !(pos is int))
                return;

            int ipos = (int)pos;

            if (ipos >= _Values.Count)
                return;

            _Values.RemoveAt(ipos);
            _Indices.Remove(name);

            ArrayList al = new ArrayList();

            foreach (DictionaryEntry de in _Indices)
                if ((int)de.Value > ipos)
                    al.Add(de.Key);

            foreach (string key in al)
                _Indices[key] = ((int)_Indices[key]) - 1;
        }

Usage Example

Example #1
0
        private void LoadPropertyValue(SettingsPropertyCollection collection, SettingElement element, bool allowOverwrite)
        {
            SettingsProperty prop = collection [element.Name];

            if (prop == null)               // see bug #343459
            {
                prop = new SettingsProperty(element.Name);
                collection.Add(prop);
            }

            SettingsPropertyValue value = new SettingsPropertyValue(prop);

            value.IsDirty         = false;
            value.SerializedValue = element.Value.ValueXml != null ? element.Value.ValueXml.InnerText : prop.DefaultValue;
            try
            {
                if (allowOverwrite)
                {
                    values.Remove(element.Name);
                }
                values.Add(value);
            } catch (ArgumentException) {
                throw new ConfigurationErrorsException();
            }
        }
All Usage Examples Of System.Configuration.SettingsPropertyValueCollection::Remove