Freigeben über


IsolatedStorageSettings.Remove Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Removes the entry with the specified key.

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

Syntax

'Declaration
Public Function Remove ( _
    key As String _
) As Boolean
public bool Remove(
    string key
)

Parameters

Return Value

Type: System.Boolean
true if the specified key was removed; otherwise, false.

Implements

IDictionary<TKey, TValue>.Remove(TKey)

Exceptions

Exception Condition
ArgumentNullException

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

Remarks

Use this method to remove key-value pairs from isolated storage. If the key does not exist, the method returns false; no entry is deleted and no exception is thrown.

Examples

The following example tries to remove a key-value pair for the user's name from the settings dictionary. A message is displayed in a TextBox named tbResults that indicates whether the name was removed or not found. This example is part of a larger example for the IsolatedStorageSettings class.

If userSettings.Remove("name") = True Then
    tbResults.Text = "Name removed. Refresh page to see changes."
Else
    tbResults.Text = "Name could not be removed. Key does not exist."
End If
if (userSettings.Remove("name") == true)
{
    tbResults.Text = "Name removed. Refresh page to see changes.";
}
else
{
    tbResults.Text = "Name could not be removed. Key does not exist.";
}

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

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