Method ReadAsString
ReadAsString(Stream)
Reads the contents of stream from it's current point to the end and returns the result as a string.
Declaration
public static string ReadAsString(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream to read from. |
Returns
Type | Description |
---|---|
System.String | A System.String representation of the stream contents. |
Remarks
This overload uses the System.Text.UTF8Encoding to convert the stream contents into a string.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |
System.InvalidOperationException | Thrown if the stream length is greater than System.Int32.MaxValue. |
ReadAsString(Stream, Encoding)
Reads the contents of stream from it's current point to the end and returns the result as a string.
Declaration
public static string ReadAsString(Stream stream, Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
Encoding | encoding | The text encoding to use when decoding the stream into a string. |
Returns
Type | Description |
---|---|
System.String | A System.String representation of the stream contents. |