StringCollection.IList.Add(Object) 方法

定义

将对象添加到 StringCollection 的结尾处。Adds an object to the end of the StringCollection.

 virtual int System.Collections.IList.Add(System::Object ^ value) = System::Collections::IList::Add;
int IList.Add (object value);
int IList.Add (object? value);
abstract member System.Collections.IList.Add : obj -> int
override this.System.Collections.IList.Add : obj -> int
Function Add (value As Object) As Integer Implements IList.Add

参数

value
Object

要添加到 Object 的结尾处的 StringCollectionThe Object to be added to the end of the StringCollection. 该值可以为 nullThe value can be null.

返回

Int32

已添加 valueStringCollection 索引。The StringCollection index at which the value has been added.

实现

例外

StringCollection 为只读。The StringCollection is read-only.

- 或 --or- StringCollection 具有固定的大小。The StringCollection has a fixed size.

注解

StringCollection 接受 null 作为有效值,并允许重复元素。StringCollection accepts null as a valid value and allows duplicate elements.

如果 Count 已等于容量,则会 StringCollection 自动重新分配内部数组,并将现有元素复制到新数组,然后再添加新的元素。If Count already equals the capacity, the capacity of the StringCollection 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.

适用于

另请参阅