Public Function Remove ( _ key As TKey _ ) As Boolean
Dim instance As Dictionary(Of TKey, TValue) Dim key As TKey Dim returnValue As Boolean returnValue = instance.Remove(key)
public bool Remove ( TKey key )
public: virtual bool Remove ( TKey key ) sealed
public final boolean Remove ( TKey key )
public final function Remove ( key : TKey ) : boolean
要移除的元素的键。
ArgumentNullException
key 为 空引用(在 Visual Basic 中为 Nothing)。
如果 Dictionary 不包含带有指定键的元素,则 Dictionary 保持不变。不引发异常。
此方法的运算复杂度接近 O(1)。
下面的代码示例演示如何使用 Remove 方法从字典中移除键/值对。
此代码示例摘自一个为 Dictionary 类提供的更大的示例。
' Use the Remove method to remove a key/value pair. Console.WriteLine(vbLf + "Remove(""doc"")") openWith.Remove("doc") If Not openWith.ContainsKey("doc") Then Console.WriteLine("Key ""doc"" is not found.") End If
// Use the Remove method to remove a key/value pair. Console.WriteLine("\nRemove(\"doc\")"); openWith.Remove("doc"); if (!openWith.ContainsKey("doc")) { Console.WriteLine("Key \"doc\" is not found."); }
Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。