.NET Framework Class Library for Silverlight
IsolatedStorageSettings..::.Add Method

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

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

Visual Basic (Declaration)
Public Sub Add ( _
    key As String, _
    value As Object _
)
Visual Basic (Usage)
Dim instance As IsolatedStorageSettings
Dim key As String
Dim value As Object

instance.Add(key, value)
C#
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<(Of <(TKey, TValue>)>)..::.Add(TKey, TValue)
Exceptions

ExceptionCondition
ArgumentNullException

key is nullNothingnullptra null reference (Nothing in Visual Basic).

ArgumentException

key already exists in the dictionary.

Remarks

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

Examples

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.

Visual Basic
Try
    userSettings.Add("name", tbName.Text)
    tbResults.Text = "Name saved. Refresh page to see changes."
Catch ex As ArgumentException
    tbResults.Text = ex.Message
End Try
C#
try
{
    userSettings.Add("name", tbName.Text);
    tbResults.Text = "Name saved. Refresh page to see changes.";
}
catch (ArgumentException ex)
{
    tbResults.Text = ex.Message;
}
Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference

Other Resources

Tags :


Page view tracker