ParserErrorCollection.AddRange 方法

定義

ParserError 物件加入集合中。Adds ParserError objects to a collection.

多載

AddRange(ParserError[])

ParserError 物件陣列加入集合。Adds an array of ParserError objects to the collection.

AddRange(ParserErrorCollection)

將現有 ParserErrorCollection 中的物件加入集合中。Adds the objects in an existing ParserErrorCollection to the collection.

AddRange(ParserError[])

ParserError 物件陣列加入集合。Adds an array of ParserError objects to the collection.

public:
 void AddRange(cli::array <System::Web::ParserError ^> ^ value);
public void AddRange (System.Web.ParserError[] value);
member this.AddRange : System.Web.ParserError[] -> unit
Public Sub AddRange (value As ParserError())

參數

value
ParserError[]

ParserError 型別的陣列,指定要加入此集合中的值。An array of type ParserError that specifies the values to add to the collection.

例外狀況

valuenullvalue is null.

範例

下列程式碼範例示範如何將物件範圍新增 ParserErrorParserErrorCollection 物件。The following code example demonstrates how to add a range of ParserError objects to a ParserErrorCollection object.

// Add an array of ParserError objects to the collection.
ParserError[] errors = 
    { new ParserError("Error 2", "Path", 1), 
    new ParserError("Error 3", "Path", 1) };
collection.AddRange(errors);

// Add a collection of ParserError objects to the collection.
ParserErrorCollection errorsCollection = new ParserErrorCollection();
errorsCollection.Add(new ParserError("Error", "Path", 1));
errorsCollection.Add(new ParserError("Error", "Path", 1));
collection.AddRange(errorsCollection);
' Add an array of ParserError objects to the collection.
Dim errors As ParserError() = _
    {New ParserError("Error 2", "Path", 1), _
    New ParserError("Error 3", "Path", 1)}
collection.AddRange(errors)

' Ads a collection of ParserError objects to the collection.
Dim errorsCollection As New ParserErrorCollection()
errorsCollection.Add(New ParserError("Error", "Path", 1))
errorsCollection.Add(New ParserError("Error", "Path", 1))
collection.AddRange(errorsCollection)

備註

AddRange 可以使用方法,將物件的陣列加入 ParserError 至集合。Use the AddRange method to add an array of ParserError objects to the collection. AddRange當您建立多個 ParserError 物件,並且想要使用單一方法呼叫將它們新增至集合時,此方法很有用。The AddRange method is useful when you create multiple ParserError objects and want to add them to the collection with a single method call. 若要將個別 ParserError 物件加入至集合,請使用 Add 方法。To add individual ParserError objects to the collection, use the Add method.

適用於

AddRange(ParserErrorCollection)

將現有 ParserErrorCollection 中的物件加入集合中。Adds the objects in an existing ParserErrorCollection to the collection.

public:
 void AddRange(System::Web::ParserErrorCollection ^ value);
public void AddRange (System.Web.ParserErrorCollection value);
member this.AddRange : System.Web.ParserErrorCollection -> unit
Public Sub AddRange (value As ParserErrorCollection)

參數

value
ParserErrorCollection

ParserErrorCollection,包含要加入至集合的 ParserError 物件。A ParserErrorCollection containing the ParserError objects to add to the collection.

例外狀況

ParserError 值為 nullThe ParserError value is null.

範例

下列程式碼範例示範如何將物件範圍新增 ParserErrorParserErrorCollection 物件。The following code example demonstrates how to add a range of ParserError objects to a ParserErrorCollection object.

// Add an array of ParserError objects to the collection.
ParserError[] errors = 
    { new ParserError("Error 2", "Path", 1), 
    new ParserError("Error 3", "Path", 1) };
collection.AddRange(errors);

// Add a collection of ParserError objects to the collection.
ParserErrorCollection errorsCollection = new ParserErrorCollection();
errorsCollection.Add(new ParserError("Error", "Path", 1));
errorsCollection.Add(new ParserError("Error", "Path", 1));
collection.AddRange(errorsCollection);
' Add an array of ParserError objects to the collection.
Dim errors As ParserError() = _
    {New ParserError("Error 2", "Path", 1), _
    New ParserError("Error 3", "Path", 1)}
collection.AddRange(errors)

' Ads a collection of ParserError objects to the collection.
Dim errorsCollection As New ParserErrorCollection()
errorsCollection.Add(New ParserError("Error", "Path", 1))
errorsCollection.Add(New ParserError("Error", "Path", 1))
collection.AddRange(errorsCollection)

備註

不同于 Add 方法,方法沒有傳回 AddRange 值,可用來判斷 ParserError 正在加入的物件是否已存在於集合中。Unlike the Add method, the AddRange method does not have a return value that can be used to determine whether a ParserError object being added is already in the collection. 如果您需要此資訊,請 Contains 在使用之前使用 AddRange 方法。If you need this information, use the Contains method before using AddRange.

適用於