Complete the code to read all bytes from a stream synchronously.
using var stream = new MemoryStream(data); byte[] buffer = new byte[stream.Length]; stream.[1](buffer, 0, buffer.Length);
The Read method reads bytes synchronously from the stream into the buffer.
Complete the code to asynchronously read bytes from a stream.
using var stream = new MemoryStream(data); byte[] buffer = new byte[stream.Length]; await stream.[1](buffer, 0, buffer.Length);
The ReadAsync method reads bytes asynchronously from the stream into the buffer.
Fix the error in the async stream reading loop.
await foreach (var chunk in stream.[1]()) { Process(chunk); }
The ReadChunksAsync method returns an async stream of chunks to iterate over asynchronously.
Fill both blanks to create a dictionary comprehension that maps words to their lengths only if length is greater than 3.
var lengths = new Dictionary<string, int> { { [1], [2] } };
foreach (var word in words)
{
if (word.Length > 3)
lengths[word] = word.Length;
}The key is the word itself, and the value is its length.
Fill all three blanks to create an async enumerable that yields uppercase words longer than 4 characters.
async IAsyncEnumerable<string> GetFilteredWords(IEnumerable<string> words)
{
foreach (var [1] in words)
{
if ([2] > 4)
yield return [3];
}
}We iterate over each word, check if its length is greater than 4, and yield the uppercase version.