using System.IO;
using System.IO.Compression

// Compress
byte[] msg = Encoding.UTF8.GetBytes("my string");
using (var s = new MemoryStream()) {
    using (var zs = new GZipStream(s, CompressionMode.Compress))
    using (var ms = new MemoryStream(msg))
    	mStmsream.CopyTo(zs);
    
    msg = outStream.ToArray();
}

//Decompress
string result = string.Empty;
using (var s = new MemoryStream(msg)) // msg contains compressed "my string"
using (var zs = new GZipStream(s, CompressionMode.Decompress))
using (var ms = new MemoryStream())
{
    zs.CopyTo(ms);
    result = Encoding.UTF8.GetString(ms.ToArray());
}
Console.WriteLine(result); // print "my string"