System.Configuration.KeyValueConfigurationCollection.Add C# (CSharp) Метод

Add() публичный Метод

public Add ( KeyValueConfigurationElement keyValue ) : void
keyValue KeyValueConfigurationElement
Результат void
        public void Add(KeyValueConfigurationElement keyValue) {
            // Need to initialize in order to get the key
            keyValue.Init();

            // the appsettings add works more like a namevalue collection add in that it appends values
            // when add is called and teh key already exists.
            KeyValueConfigurationElement oldValue = (KeyValueConfigurationElement)BaseGet(keyValue.Key);
            if (oldValue == null) {
                BaseAdd(keyValue);
            }
            else {
                oldValue.Value += "," + keyValue.Value;
                int index = BaseIndexOf(oldValue);
                BaseRemoveAt(index);
                BaseAdd(index, oldValue);
            }


        }

Same methods

KeyValueConfigurationCollection::Add ( String key, String value ) : void

Usage Example

Пример #1
0
        private static KeyValueConfigurationCollection GetKeyValueCollection()
        {
            var collection = new KeyValueConfigurationCollection();
            collection.Add("Name", "Value");
            collection.Add("Email", "*****@*****.**");
            collection.Add("Company", "IBM");
            collection.Add("Year", "2011");

            return collection;
        }
All Usage Examples Of System.Configuration.KeyValueConfigurationCollection::Add