You need to write a code segment that transfers the contents of a byte array named dataToSend
by using a NetworkStream object named netStream.
You need to use a cache of size 8,192 bytes.
Which code segment should you use?
A.
MemoryStream memStream = new MemoryStream(8192);
memStream.Write(dataToSend, 0, (int) netStream.Length);
B.
MemoryStream memStream = new MemoryStream(8192);
netStream.Write(dataToSend, 0, (int) memStream.Length);
C.
BufferedStream bufStream = new BufferedStream(netStream, 8192);
bufStream.Write(dataToSend, 0, dataToSend.Length);
D.
BufferedStream bufStream = new BufferedStream(netStream);
bufStream.Write(dataToSend, 0, 8192);
Explanation:
To send data using a cache it is necessary to use a BufferedStream. The BufferedStream should be created with the cache size of 8192 bytes.
A & B do not employ caching.
D does not correctly initialise the BufferedStream to have a cache size of 8192 bytes.
I have the same idea. C