Home »
VB.Net »
VB.Net Programs
VB.Net program to demonstrate the StringWriter class
By Nidhi Last Updated : November 13, 2024
StringWriter Class Example in VB.Net
Here, we will use WriteLine() method of StringWriter class to write data into the stream and then print saved information on the console screen.
Program/Source Code:
The source code to demonstrate the StringWriter class is given below. The given program is compiled and executed successfully.
VB.Net code to demonstrate the example of StringWriter class
'Vb.Net program to demonstrate StringWriter class.
Imports System.IO
Imports System.Text
Module Module1
Sub Main()
Dim obj As New StringWriter(New StringBuilder())
obj.WriteLine(vbTab & "It is a book.")
obj.WriteLine(vbTab & "It is a table.")
obj.WriteLine(vbTab & "It is a fan.")
obj.Flush()
obj.Close()
Console.WriteLine("Information:")
Console.WriteLine(obj)
End Sub
End Module
Output
Information:
It is a book.
It is a table.
It is a fan.
Press any key to continue . . .
Explanation
In the above program, we created a class module Module1 that a Main() function. The Main() method is the entry point of the program, here we write the data into the stream using WriteLine() method of StringWriter class and then print saved information on the console screen.
VB.Net StringReader, StringWriter, Stream Programs »