Export (0) Print
Expand All

X509Certificate.Equals Method

Compares two objects for equality.

Overload List

Compares two X509Certificate objects for equality.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Overridable Function Equals(X509Certificate) As Boolean
[C#] public virtual bool Equals(X509Certificate);
[C++] public: virtual bool Equals(X509Certificate*);
[JScript] public function Equals(X509Certificate) : Boolean;

Inherited from Object.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Overridable Function Equals(Object) As Boolean
[C#] public virtual bool Equals(object);
[C++] public: virtual bool Equals(Object*);
[JScript] public function Equals(Object) : Boolean;

Example

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of Equals. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Imports System
Imports System.Security.Cryptography.X509Certificates




Public Class X509
   
   
   Public Shared Sub Main()
      
      ' The path to the certificate.
      Dim Certificate As String = "Certificate.cer"
      Dim OtherCertificate As String = "OtherCertificate.cer"
      
      ' Load the certificate into an X509Certificate object.
      Dim cert As X509Certificate = X509Certificate.CreateFromCertFile(Certificate)
      
      ' Load the certificate into an X509Certificate object.
      Dim certTwo As X509Certificate = X509Certificate.CreateFromCertFile(OtherCertificate)
      
      ' Get the value.
      Dim result As Boolean = cert.Equals(certTwo)
      
      ' Display the value to the console.
      Console.WriteLine(result)
   End Sub  
End Class 


[C#] 

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


public class X509
{

    public static void Main()
    {

        // 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 to the console.
        Console.WriteLine(result);
  
    }

}

[C++] 

#using <mscorlib.dll>
using namespace System;
using namespace System::Security::Cryptography::X509Certificates;

int main()
{

    // The path to the certificate.
    String* Certificate =  S"Certificate.cer";
    String* OtherCertificate =  S"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 to the console.
    Console::WriteLine(result);

}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

X509Certificate Class | X509Certificate Members | System.Security.Cryptography.X509Certificates Namespace

Show:
© 2015 Microsoft