Following code shows how:
// create client and connect
Sftp client = new Sftp();
client.Connect(hostname);
// instead of loading it from a disk file, load the private key from a byte array
//SshPrivateKey privateKey = new SshPrivateKey("key_rsa.pem", "password");
byte[] privateKeyData = YourMethodForObtainingPrivateKey();
SshPrivateKey privateKey = new SshPrivateKey(privateKeyData, "password");
// authenticate
client.Login(username, privateKey);
// ...