ExtensionMethod.NET Home of 818 C#, Visual Basic, F# and Javascript extension methods

ToStream

Returns a stream when given a string

Source

<Extension()> _
Public Function ToStream(ByVal Source As String) As System.IO.MemoryStream
    Dim Bytes() As Byte = System.Text.Encoding.ASCII.GetBytes(Source)
    Return New System.IO.MemoryStream(Bytes)
End Function

Example

Dim MyStream as Stream = "Fred".ToStream

Author: Rory Becker

Submitted on: 7 feb 2011

Language: VB

Type: System.String

Views: 2627