You are writing a method to compress an array of bytes. The bytes to be compressed are passed
to the method in a parameter named document.
You need to compress the contents of the incoming parameter.
Which code segment should you use?
A. MemoryStream inStream = new MemoryStream(document);GZipStream zipStream =
new GZipStream(inStream,
CompressionMode.Compress); byte[] result = new
Byte[document.Length];zipStream.Write(result, 0, result.Length); return result;
B. MemoryStream Stream = new MemoryStream(document);GZipStream zipStream =
new GZipStream(stream,
CompressionMode.Compress);zipStream.Write(document, 0,
document.Length);zipStream.Close();return stream.ToArray();
C. MemoryStream outStream = new MemoryStream();GZipStream zipStream = new
GZipStream(outStream,
CompressionMode.Compress);zipStream.Write(document, 0,
document.Length);zipStream.Close();return outStream.ToArray();
D. MemoryStream inStream = new MemoryStream(document);GZipStream zipStream =
new GZipStream(inStream,
CompressionMode.Compress); MemoryStream outStream = new MemoryStream();int b;while
((b = zipStream.ReadByte()) != -1) {
outStream.WriteByte((byte)b);} return outStream.ToArray();
Answer: C
to the method in a parameter named document.
You need to compress the contents of the incoming parameter.
Which code segment should you use?
A. MemoryStream inStream = new MemoryStream(document);GZipStream zipStream =
new GZipStream(inStream,
CompressionMode.Compress); byte[] result = new
Byte[document.Length];zipStream.Write(result, 0, result.Length); return result;
B. MemoryStream Stream = new MemoryStream(document);GZipStream zipStream =
new GZipStream(stream,
CompressionMode.Compress);zipStream.Write(document, 0,
document.Length);zipStream.Close();return stream.ToArray();
C. MemoryStream outStream = new MemoryStream();GZipStream zipStream = new
GZipStream(outStream,
CompressionMode.Compress);zipStream.Write(document, 0,
document.Length);zipStream.Close();return outStream.ToArray();
D. MemoryStream inStream = new MemoryStream(document);GZipStream zipStream =
new GZipStream(inStream,
CompressionMode.Compress); MemoryStream outStream = new MemoryStream();int b;while
((b = zipStream.ReadByte()) != -1) {
outStream.WriteByte((byte)b);} return outStream.ToArray();
Answer: C
No comments:
Post a Comment