public static void ReadWriteC(this BitcoinStream bs, ref RsaPubKey pubKey) { if (bs.Serializing) { var bytes = pubKey == null ? new byte[0] : pubKey.ToBytes(); bs.ReadWriteAsVarString(ref bytes); } else { byte[] bytes = null; bs.ReadWriteAsVarString(ref bytes); pubKey = bytes.Length == 0 ? null : new RsaPubKey(bytes); } }