The ToXmlString method creates an XML string that contains either the public and private key of the current RSA object or contains only the public key of the current RSA object.
Use the ToXmlString method whenever you need to conveniently persist RSA key information. To initialize an RSA object with the key in an XML string, use the FromXmlString method.
Persisting an XML string containing a private key to an insecure location is a security threat. The security of your application can be compromised if a malicious third party can access your private key. To safely persist a private key, use a secure key container. For more information about persisting private keys in a key container, see How to: Store Asymmetric Keys in a Key Container.
When you pass true to the ToXmlString method, the resulting XML string takes the following form:
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)