StringWriter and StringReader

StringWriter Class Implements a TextWriter for writing information to a string and the information is stored in an underlying StringBuilder Class. StringBuilder Class Represents a mutable string of characters and this class cannot be inherited.

WriteLine(String) method writes a string followed by a line terminator to the text stream.

StringReader Class Implements a TextReader that reads from a string. StringReader.ReadLine Method Reads a line from the underlying string.

The next line from the underlying string, or Nothing if the end of the underlying string is reached.

The following program shows how to use StringWriter and StringReader Classes in VB.NET.

Imports System.IO
Public Class Form1

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Dim stringWriter As New StringWriter()


		Dim singleLine As String
		Dim message As String
		Dim stringReader As New StringReader(stringWriter.ToString)
		While True
			singleLine = stringReader.ReadLine
			If singleLine Is Nothing Then
				Exit While
				message = message & singleLine & Environment.NewLine
			End If
		End While

	End Sub
End Class (C) 2019    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.
SiteMap  | Terms  | About