NameValueCollection.Remove(String) NameValueCollection.Remove(String) NameValueCollection.Remove(String) NameValueCollection.Remove(String) Method

定義

將具有指定索引鍵的項目從 NameObjectCollectionBase 中移除。Removes the entries with the specified key from the NameObjectCollectionBase instance.

public:
 virtual void Remove(System::String ^ name);
public virtual void Remove (string name);
abstract member Remove : string -> unit
override this.Remove : string -> unit
Public Overridable Sub Remove (name As String)

參數

name
String String String String

要移除的項目的 String 索引鍵。The String key of the entry to remove. 這個索引鍵可以是 nullThe key can be null.

例外狀況

備註

如果NameValueCollection未包含與指定之索引鍵的項目NameValueCollection會維持不變。If the NameValueCollection doesn't contain an element with the specified key, the NameValueCollection remains unchanged. 不會有例外狀況擲回。No exception is thrown.

如果您指定null值加入name參數,有的項目null移除索引鍵時,如果找到。If you specify a null value to the name parameter, an entry with a null key is removed, if found.

在相鄰元素的集合中,例如清單,接在移除的元素之後的元素會向上移動以佔用空出的位置。In collections of contiguous elements, such as lists, the elements that follow the removed element move up to occupy the vacated spot. 如果集合具有索引,則移動之項目的索引也會更新。If the collection is indexed, the indexes of the elements that are moved are also updated. 集合的項目若在概念上群組成 Bucket (例如雜湊資料表),則不適用這項行為。This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hash table.

這個方法是 O (n) 運算,其中nCountThis method is an O(n) operation, where n is Count.

適用於

另請參閱