0% found this document useful (0 votes)
2 views

complete-reference-vb_net_63

Uploaded by

khalid
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

complete-reference-vb_net_63

Uploaded by

khalid
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

StringReader/StringWriter

ReadLine Reads a line from the underlying string


ReadToEnd Reads to the end of the text stream
Table 15−28: The Members of the StringWriter Class

Member Purpose
Encoding (p) Retrieves the encoding in which the output is written
FormatProvider (p) Retrieves an object that controls formatting
NewLine (p) Retrieves or changes the line terminator string used by the current
TextWriter
Close Closes the current StringWriter and the underlying stream
CreateObjRef Creates an object that contains all the relevant information required to
generate a proxy used to communicate with a remote object
Flush Clears all buffers for the current writer and causes any buffered data to be
written to the underlying device
GetLifetimeService Retrieves the current lifetime service object that controls the lifetime policy
for this instance
GetStringBuilder Returns the underlying StringBuilder object
Write Writes to this instance of the StringWriter
WriteLine Writes some data as specified by the overloaded parameters, followed by a
line terminator
Write

User the Write method to write data to an object that can receive a text input stream, such as StringBuilder.
The following code illustrates writing to a StringBuilder object:

Public Sub AddWords(ByVal source As String, ByVal newword As String)


Dim sBuilder As New StringBuilder()
Dim strWriter As New StringWriter(sBuilder)
strWriter.Write(newword)
'check if write worked
Console.WriteLine(sBuilder)
End Sub

Write does not force a new line, and new text is either appended to the existing text or, depending on the
object, overwrites it.

WriteLine

The WriteLine method works exactly like Write, but adds a line terminator to the end of the String, which
forces a new line. This is demonstrated as follows:

Console.WriteLine(sBuilder)

GetStringBuilder

The GetStringBuilder method will return an instance of StringBuilder that you can write to. Append and
insert your characters to the object as demonstrated in the earlier "Building Strings with StringBuilder"
section and then simply write the object to a line.

Public Sub AddChars()

547

You might also like