NameValueCollection.Add NameValueCollection.Add NameValueCollection.Add NameValueCollection.Add Method

定義

加入項目至目前的 NameValueCollectionAdds entries to the current NameValueCollection.

多載

Add(NameValueCollection) Add(NameValueCollection) Add(NameValueCollection) Add(NameValueCollection)

將指定 NameValueCollection 中的項目複製到目前的 NameValueCollectionCopies the entries in the specified NameValueCollection to the current NameValueCollection.

Add(String, String) Add(String, String) Add(String, String) Add(String, String)

將具有指定名稱和數值的項目加入 NameValueCollectionAdds an entry with the specified name and value to the NameValueCollection.

Add(NameValueCollection) Add(NameValueCollection) Add(NameValueCollection) Add(NameValueCollection)

將指定 NameValueCollection 中的項目複製到目前的 NameValueCollectionCopies the entries in the specified NameValueCollection to the current NameValueCollection.

public:
 void Add(System::Collections::Specialized::NameValueCollection ^ c);
public void Add (System.Collections.Specialized.NameValueCollection c);
member this.Add : System.Collections.Specialized.NameValueCollection -> unit
Public Sub Add (c As NameValueCollection)

參數

例外狀況

備註

c如果目標NameValueCollection實例中已經有索引鍵, 則中c的相關聯值會加入至目標NameValueCollection實例中與相同索引鍵相關聯之值的現有逗號分隔清單中。If a key in c already exists in the target NameValueCollection instance, the associated value in c is added to the existing comma-separated list of values associated with the same key in the target NameValueCollection instance.

如果Count已經等於容量, 則的容量會藉NameValueCollection由自動重新配置內部陣列來增加, 而現有的專案會先複製到新的陣列, 然後才新增新的元素。If Count already equals the capacity, the capacity of the NameValueCollection is increased by automatically reallocating the internal array, and the existing elements are copied to the new array before the new element is added.

如果Count小於容量, 這個方法會是 O (1) 運算。If Count is less than the capacity, this method is an O(1) operation. 如果需要增加容量以容納新的元素, 這個方法會變成 O (n) 運算, 其中nCountIf the capacity needs to be increased to accommodate the new element, this method becomes an O(n) operation, where n is Count.

另請參閱

Add(String, String) Add(String, String) Add(String, String) Add(String, String)

將具有指定名稱和數值的項目加入 NameValueCollectionAdds an entry with the specified name and value to the NameValueCollection.

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

參數

name
String String String String

要加入之項目的 String 索引鍵。The String key of the entry to add. 這個索引鍵可以是 nullThe key can be null.

value
String String String String

要加入之項目的 String 值。The String value of the entry to add. 這個值可以是 nullThe value can be null.

例外狀況

備註

如果指定的索引鍵已存在於目標NameValueCollection實例中, 則會將指定的值加入表單"value1,value2,value3"中以逗號分隔的現有值清單。If the specified key already exists in the target NameValueCollection instance, the specified value is added to the existing comma-separated list of values in the form "value1,value2,value3". 值與目標NameValueCollection實例中的相同索引鍵相關聯。The values are associated with the same key in the target NameValueCollection instance.

如果Count已經等於容量, 則的容量會藉NameValueCollection由自動重新配置內部陣列來增加, 而現有的專案會先複製到新的陣列, 然後才新增新的元素。If Count already equals the capacity, the capacity of the NameValueCollection is increased by automatically reallocating the internal array, and the existing elements are copied to the new array before the new element is added.

如果Count小於容量, 這個方法會是 O (1) 運算。If Count is less than the capacity, this method is an O(1) operation. 如果需要增加容量以容納新的元素, 這個方法會變成 O (n) 運算, 其中nCountIf the capacity needs to be increased to accommodate the new element, this method becomes an O(n) operation, where n is Count.

適用於