Skip to content

Commit 5ef0e00

Browse files
Update strmreader read2.cs
.NET source code clearly shows Read() may not return a fixed number of characters, but only what's currently available on the stream. ReadBlock returns the stated number of characters and only returns fewer if end of stream
1 parent ac913ef commit 5ef0e00

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

snippets/csharp/System.IO/StreamReader/Read/strmreader read2.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static void Main()
3232
while (sr.Peek() >= 0)
3333
{
3434
c = new char[5];
35-
sr.Read(c, 0, c.Length);
35+
sr.ReadBlock(c, 0, c.Length);
3636
//The output will look odd, because
3737
//only five characters are read at a time.
3838
Console.WriteLine(c);

0 commit comments

Comments
 (0)