IsolatedStorageSettings.Add Method

July 28, 2014

Adds an entry to the dictionary for the key-value pair.

Namespace:  System.IO.IsolatedStorage
Assembly:  System.Windows (in System.Windows.dll)

public void Add(
	string key,
	Object value
)

Parameters

key
Type: System.String
The key for the entry to be stored.
value
Type: System.Object
The value to be stored.

Implements

IDictionary<TKey, TValue>.Add(TKey, TValue)

ExceptionCondition
ArgumentNullException

key is null.

ArgumentException

key already exists in the dictionary.

Use this method to add key-value pairs to isolated storage.

The following example tries to add a key-value pair for the user's name to the settings dictionary. If the data is added successfully, a confirmation is displayed in a TextBox named tbResults. If the key already exists, an exception message is displayed. This example is part of a larger example for the IsolatedStorageSettings class.


try
{
    userSettings.Add("name", tbName.Text);
    tbResults.Text = "Name saved. Refresh page to see changes.";
}
catch (ArgumentException ex)
{
    tbResults.Text = ex.Message;
}


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2014 Microsoft