X509Certificate.ToString Método

Definición

Devuelve una representación en forma de cadena del objeto X509Certificate actual.

Sobrecargas

ToString()

Devuelve una representación en forma de cadena del objeto X509Certificate actual.

ToString(Boolean)

Devuelve una representación en forma de cadena del objeto X509Certificate actual con información adicional, si se especifica.

ToString()

Devuelve una representación en forma de cadena del objeto X509Certificate actual.

C#
public override string ToString ();

Devoluciones

String

Representación en forma de cadena del objeto X509Certificate actual.

Ejemplos

En el ejemplo siguiente se usa el ToString método para mostrar el valor de un certificado en la consola.

C#

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

public class X509
{

    public static void Main()
    {

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

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

        // Get the value.
        string resultsTrue = cert.ToString(true);

        // Display the value to the console.
        Console.WriteLine(resultsTrue);

        // Get the value.
        string resultsFalse = cert.ToString(false);

        // Display the value to the console.
        Console.WriteLine(resultsFalse);
    }
}

Se aplica a

.NET 7 otras versiones
Producto Versiones
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
.NET Standard 1.3, 1.4, 1.6, 2.0, 2.1

ToString(Boolean)

Devuelve una representación en forma de cadena del objeto X509Certificate actual con información adicional, si se especifica.

C#
public virtual string ToString (bool fVerbose);

Parámetros

fVerbose
Boolean

Es true para generar la forma detallada de la representación en forma de cadena; en caso contrario, es false.

Devoluciones

String

Representación en forma de cadena del objeto X509Certificate actual.

Ejemplos

En el ejemplo siguiente se usa el ToString método para mostrar el valor de un certificado en la consola.

C#

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

public class X509
{

    public static void Main()
    {

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

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

        // Get the value.
        string resultsTrue = cert.ToString(true);

        // Display the value to the console.
        Console.WriteLine(resultsTrue);

        // Get the value.
        string resultsFalse = cert.ToString(false);

        // Display the value to the console.
        Console.WriteLine(resultsFalse);
    }
}

Se aplica a

.NET 7 otras versiones
Producto Versiones
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
.NET Standard 1.3, 1.4, 1.6, 2.0, 2.1