ADVERTISEMENT
ADVERTISEMENT

VB.Net program to demonstrate the StringWriter class

Here, we are going to demonstrate the StringWriter class in VB.Net.
Submitted by Nidhi, on January 06, 2021

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



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.