• Home
  • API Documentation
Show / Hide Table of Contents
  • McStreamy
    • ByteArrayExtensions
      • ToStream
    • NonClosingStreamAdapter
      • CanRead
      • CanSeek
      • CanTimeout
      • CanWrite
      • Dispose
      • Flush
      • Length
      • NonClosingStreamAdapter
      • Position
      • Read
      • ReadByte
      • ReadTimeout
      • Seek
      • SetLength
      • ToString
      • Write
      • WriteByte
      • WriteTimeout
    • StreamExtensions
      • ReadAllBytes
      • ReadAllBytesAsync
      • ReadAsString
      • ReadAsStringAsync
      • WriteAllBytes
      • WriteAllBytesAsync
    • StringExtensions
      • ToStream

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 stream is null.

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.

Back to top Copyright (c) 2017 Troy Willmot