X509Certificate.Equals Method (Object)

Compares two X509Certificate objects for equality.

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

[ComVisibleAttribute(false)]
public override bool Equals(
	Object obj
)

Parameters

obj
Type: System.Object
An object to compare to the current object.

Return Value

Type: System.Boolean
true if the current X509Certificate object is equal to the object specified by the other parameter; otherwise, false.

The following example compares two certificates for equality.



using System;
using System.Security.Cryptography.X509Certificates;


public class Example
{

   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {

      // The path to the certificate.
      string Certificate = "Certificate.cer";
      string OtherCertificate = "OtherCertificate.cer";

      // Load the certificate into an X509Certificate object.
      X509Certificate cert = X509Certificate.CreateFromCertFile(Certificate);

      // Load the certificate into an X509Certificate object.
      X509Certificate certTwo = X509Certificate.CreateFromCertFile(OtherCertificate);

      // Get the value.
      bool result = cert.Equals(certTwo);

      // Display the value.
      outputBlock.Text += result + "\n";

   }

}


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show: