I 've been looking up this sample code for working with GZipStream (compressing string to byte array and vice versa) several times now. There are numerous samples available that show how to work with GZipStream, but most of them seem overly complex for the task at hand. I've settled on this version:

   public static byte Compress(string text)
   {
       using (var ms = new MemoryStream())
       {
           using (var zip = new GZipStream(ms, 
                                         CompressionMode.Compress))
           using (var writer = new StreamWriter(zip, Encoding.UTF8))
           {
               writer.Write(text);
           }
           return ms.ToArray();
        }
   }
   public static string Decompress(byte[] compressed)
   {
       using (var ms = new MemoryStream(compressed))
       using (var zip = new GZipStream(ms, CompressionMode.Decompress))
       using (var sr = new StreamReader(zip, Encoding.UTF8))
       {
           return sr.ReadToEnd();
       }
   }