• 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 ToStream

ToStream(String)

Creates a new (memory) stream containing the UTF-8 bytes from the string specified.

Declaration
public static Stream ToStream(this string value)
Parameters
Type Name Description
System.String value

The string to use as the content for the stream.

Returns
Type Description
System.IO.Stream

A System.IO.MemoryStream typed as a System.IO.Stream.

Exceptions
Type Condition
System.ArgumentNullException

Thrown if value is null.

ToStream(String, Encoding)

Creates a new (memory) stream containing the bytes from the string specified, using the provided encoding to convert the string into byte content.

Declaration
public static Stream ToStream(this string value, Encoding encoding)
Parameters
Type Name Description
System.String value

The string to use as the content for the stream.

System.Text.Encoding encoding

The text encoding to use when converting the string into bytes content for the returned stream.

Returns
Type Description
System.IO.Stream

A System.IO.MemoryStream typed as a System.IO.Stream.

Exceptions
Type Condition
System.ArgumentNullException

Thrown if value or encoding is null.

Back to top Copyright (c) 2017 Troy Willmot