Export (0) Print
Expand All

AsymmetricAlgorithm.ToXmlString Method

When overridden in a derived class, creates and returns an XML string representation of the current AsymmetricAlgorithm object.

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

public abstract string ToXmlString (
	bool includePrivateParameters
)
public abstract String ToXmlString (
	boolean includePrivateParameters
)
public abstract function ToXmlString (
	includePrivateParameters : boolean
) : String

Parameters

includePrivateParameters

true to include private parameters; otherwise, false.

Return Value

An XML string encoding of the current AsymmetricAlgorithm object.

The following code example demonstrates how to call the ToXmlString method to create an XML representation of the parameters in the current AsymmetricAlgorithm object. This code example is part of a larger example provided for the AsymmetricAlgorithm class.

public override string ToXmlString(bool includePrivateParameters)
{
    string keyContainerName = "";
    string keyNumber = "";
    string providerName = "";
    string providerType = "";

    if (cspParameters != null)
    {
        keyContainerName = cspParameters.KeyContainerName;
        keyNumber = cspParameters.KeyNumber.ToString();
        providerName = cspParameters.ProviderName;
        providerType = cspParameters.ProviderType.ToString();
    }

    StringBuilder sb = new StringBuilder();
    sb.Append("<CustomCryptoKeyValue>");

    sb.Append("<KeyContainerName>");
    sb.Append(keyContainerName);
    sb.Append("</KeyContainerName>");

    sb.Append("<KeyNumber>");
    sb.Append(keyNumber);
    sb.Append("</KeyNumber>");

    sb.Append("<ProviderName>");
    sb.Append(providerName);
    sb.Append("</ProviderName>");

    sb.Append("<ProviderType>");
    sb.Append(providerType);
    sb.Append("</ProviderType>");

    sb.Append("</CustomCryptoKeyValue>");
    return(sb.ToString());
}

Windows 98, Windows 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft