OrderedDictionary.Remove(Object) Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Rimuove la voce con la chiave specificata dall'insieme OrderedDictionary .
public:
virtual void Remove(System::Object ^ key);
public void Remove(object key);
abstract member Remove : obj -> unit
override this.Remove : obj -> unit
Public Sub Remove (key As Object)
Parametri
- key
- Object
Chiave della voce da rimuovere.
Implementazioni
Eccezioni
La OrderedDictionary raccolta è di sola lettura.
key è null.
Esempio
Nell'esempio di codice seguente viene illustrata la modifica di una OrderedDictionary raccolta. In questo esempio, il Remove metodo viene usato per rimuovere la voce con la chiave "keyToDelete" da OrderedDictionary. Questo codice fa parte di un esempio di codice più ampio che può essere visualizzato in OrderedDictionary.
// Modifying the OrderedDictionary
if (!myOrderedDictionary.IsReadOnly)
{
// Insert a new key to the beginning of the OrderedDictionary
myOrderedDictionary.Insert(0, "insertedKey1", "insertedValue1");
// Modify the value of the entry with the key "testKey2"
myOrderedDictionary["testKey2"] = "modifiedValue";
// Remove the last entry from the OrderedDictionary: "testKey3"
myOrderedDictionary.RemoveAt(myOrderedDictionary.Count - 1);
// Remove the "keyToDelete" entry, if it exists
if (myOrderedDictionary.Contains("keyToDelete"))
{
myOrderedDictionary.Remove("keyToDelete");
}
}
' Modifying the OrderedDictionary
If Not myOrderedDictionary.IsReadOnly Then
' Insert a new key to the beginning of the OrderedDictionary
myOrderedDictionary.Insert(0, "insertedKey1", "insertedValue1")
' Modify the value of the entry with the key "testKey2"
myOrderedDictionary("testKey2") = "modifiedValue"
' Remove the last entry from the OrderedDictionary: "testKey3"
myOrderedDictionary.RemoveAt(myOrderedDictionary.Count - 1)
' Remove the "keyToDelete" entry, if it exists
If (myOrderedDictionary.Contains("keyToDelete")) Then
myOrderedDictionary.Remove("keyToDelete")
End If
End If
Commenti
Le voci che seguono la voce rimossa si spostano verso l'alto per occupare la posizione liberata e gli indici delle voci spostate vengono aggiornati anche.
Se la OrderedDictionary raccolta non contiene una voce con la chiave specificata, rimane OrderedDictionary invariata e non viene generata alcuna eccezione.