title: How to get RSACryptoServiceProvider public and private key only in c#
body: <p>I am running below code to get public and private key only, but it seems it outputs the whole XML format. I only need to output the keys as shown in <a href="http://travistidwell.com/jsencrypt/demo/" rel="nofollow noreferrer">Public and Private Key demo</a></p>
  
  <pre><code>        static RSACryptoServiceProvider rsa;
          private RSAParameters _privateKey;
          private RSAParameters _publicKey;
          public RSACrypto()
          {
              rsa = new RSACryptoServiceProvider(2048);
              _privateKey = rsa.ExportParameters(true);
              _publicKey = rsa.ExportParameters(false);
  
          }
          public string GetPublicKeyString()
          {
              var sw = new StringWriter();
              var xs = new XmlSerializer(typeof(RSAParameters));
              xs.Serialize(sw, _publicKey);
              return sw.ToString();
          }
          public string GetPrivateKeyString()
          {
              var sw = new StringWriter();
              var xs = new XmlSerializer(typeof(RSAParameters));
              xs.Serialize(sw, _privateKey);
              return sw.ToString();
          }
  </code></pre>