Export (0) Print
Expand All

ParserErrorCollection.Contains Method

Determines whether the ParserError object is located in the collection.

Namespace:  System.Web
Assembly:  System.Web (in System.Web.dll)

public bool Contains(
	ParserError value
)

Parameters

value
Type: System.Web.ParserError

The ParserError to locate in the collection.

Return Value

Type: System.Boolean
true if the ParserError is in the collection; otherwise, false.

You cannot add the same ParserError object to the collection more than once. However, attempting to add a ParserError object more than once will not throw an exception. Instead, the addition will fail. In this case, the Add method will return a value of –1. However, the AddRange and Insert methods do not have return values. When adding ParserError objects by using one of these methods, use the Contains method to determine whether a particular ParserError object is already in the collection.

The following code example demonstrates how to search for an instance of a specified ParserError object in a ParserErrorCollection object.

// Test for the presence of a ParserError in the 
// collection, and retrieve its index if it is found.
ParserError testError = new ParserError("Error", "Path", 1);
int itemIndex = -1;
if (collection.Contains(testError))
  itemIndex = collection.IndexOf(testError);

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft