ParserErrorCollection.Add(ParserError) 方法

定义

向集合中添加一个值。Adds a value to the collection.

public:
 int Add(System::Web::ParserError ^ value);
public int Add (System.Web.ParserError value);
member this.Add : System.Web.ParserError -> int
Public Function Add (value As ParserError) As Integer

参数

value
ParserError

要添加到集合中的 ParserError 值。The ParserError value to add to the collection.

返回

Int32

该值在集合中的索引;否则,如果集合中已存在该值,则为 -1。The index of the value within the collection; otherwise, -1 if the value is already in the collection.

示例

下面的代码示例演示如何向对象添加 ParserError 对象 ParserErrorCollectionThe following code example demonstrates how to add a ParserError object to a ParserErrorCollection object.

// Add a ParserError to the collection.
collection.Add(new ParserError("ErrorName", "Path", 1));
' Add a ParserError to the collection.
collection.Add(New ParserError("ErrorName", "Path", 1))

注解

使用 Add 方法可将现有对象添加 ParserError 到集合中。Use the Add method to add an existing ParserError object to the collection. 不能将同一个 ParserError 对象多次添加到集合中。You cannot add the same ParserError object to the collection more than once. Add 使用 ParserError 集合中已经存在的对象调用方法时,添加将失败并返回-1。When you call the Add method using a ParserError object that is already in the collection, the addition fails and -1 is returned.

若要将多个对象添加到集合,请使用 AddRange 方法。To add multiple objects to the collection, use the AddRange method.

适用于