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