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

Add() public method

public Add ( SettingsPropertyValue property ) : void
property SettingsPropertyValue
return void
        public void Add(SettingsPropertyValue property)
        {
            if (_ReadOnly)
                throw new NotSupportedException();

            int pos = _Values.Add(property);

            try
            {
                _Indices.Add(property.Name, pos);
            }
            catch (Exception)
            {
                _Values.RemoveAt(pos);
                throw;
            }
        }

Usage Example

		public void AddDuplicate ()
		{
			SettingsPropertyValueCollection col = new SettingsPropertyValueCollection ();
			SettingsProperty test_prop = new SettingsProperty ("test_prop");
			SettingsPropertyValue val = new SettingsPropertyValue (test_prop);

			col.Add (val);

			Assert.AreEqual (1, col.Count, "A1");

			col.Add (val);

			Assert.AreEqual (1, col.Count, "A2");
		}
All Usage Examples Of System.Configuration.SettingsPropertyValueCollection::Add