X509Certificate2Collection.Contains Method (X509Certificate2)

Determines whether the X509Certificate2Collection object contains a specific certificate.

Namespace: System.Security.Cryptography.X509Certificates
Assembly: System (in system.dll)

public bool Contains (
	X509Certificate2 certificate
public boolean Contains (
	X509Certificate2 certificate
public function Contains (
	certificate : X509Certificate2
) : boolean
Not applicable.



The X509Certificate2 object to locate in the collection.

Return Value

true if the X509Certificate2Collection contains the specified certificate; otherwise, false.

Exception typeCondition


certificate is a null reference (Nothing in Visual Basic).

This method performs a linear search; therefore, the average execution time is proportional to the Count property. That is, this method is an O(n) operation, where n is Count.

This method determines equality by calling the Object.Equals method.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions