title: Compress byte[] in c#
body: <p>i have a method which Decompress byte array and i need opposite of this function(mean Compress).i googeled a lot but didnot find exactly opposit of this function</p>
  
  <pre><code>public static byte[] Decompress(byte[] B)
  {
  
          MemoryStream ms = new MemoryStream(B);
          GZipStream gzipStream = new GZipStream((Stream)ms, CompressionMode.Decompress);
          byte[] buffer = new byte[4];
          ms.Position = checked(ms.Length - 5L);
          ms.Read(buffer, 0, 4);
          int count = BitConverter.ToInt32(buffer, 0);
          ms.Position = 0L;
          byte[] AR = new byte[checked(count - 1 + 1)];
          gzipStream.Read(AR, 0, count);
          gzipStream.Dispose();
          ms.Dispose();
          return AR;
  
  }
  </code></pre>