Share via


ReadToEnd Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Reads all characters from the current position to the end of the stream.

Namespace:  System.IO
Assembly:  System.IO (in System.IO.dll)

Syntax

'Declaration
Public Overrides Function ReadToEnd As String
public override string ReadToEnd()
public:
virtual String^ ReadToEnd() override
abstract ReadToEnd : unit -> string 
override ReadToEnd : unit -> string 
public override function ReadToEnd() : String

Return Value

Type: System. . :: . .String
The rest of the stream as a string, from the current position to the end. If the current position is at the end of the stream, returns an empty string ("").

Remarks

ReadToEnd works best when you need to read all the input from the current position to the end of the stream. If more control is needed over how many characters are read from the stream, use the Read(array<Char>[]()[][], Int32, Int32) method overload, which generally results in better performance.

ReadToEnd assumes that the stream knows when it has reached an end. For interactive protocols in which the server sends data only when you ask for it and does not close the connection, ReadToEnd might block indefinitely because it does not reach an end, and should be avoided.

Note that when using the Read method, it is more efficient to use a buffer that is the same size as the internal buffer of the stream. If the size of the buffer was unspecified when the stream was constructed, its default size is 4 kilobytes (4096 bytes).

.NET Framework Security

See Also

Reference

StreamReader Class

System.IO Namespace