In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you what is the use of VB.NET StringWriter, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
The emergence of VB.NET programming language has brought great help for developers, through the use of various classes, can help us to complete a lot of functional requirements. VB.NET StringWriter is located under the System.IO namespace. StringWriter can also replace the String class to complete string concatenation operations, which is more efficient.
A simple example of use is as follows:
Dim swA As New System.IO.
StringWriter
Dim arrStr () As String =
{"Northsnow", "Snow in the North"}
SwA.WriteLine (arrStr (0))
SwA.WriteLine (arrStr (1))
SwA.WriteLine (String.Format
("{0}-{1}-{2}", arrStr (2)
ArrStr (3), arrStr (4))
Me.TextBox1.AppendText
(Environment.NewLine)
Me.TextBox1.AppendText
(swA.ToString)
Me.TextBox1.AppendText
(Environment.NewLine)
The output of this program is:
Snow in the north of Northsnow
You must have noticed that the WriteLine method is used in this example, but the swA.WriteLine ("Northsnow") method is equivalent to
SwA.Write ("Northsnow") swA.Write (swA.NewLine)
You can also write information to StringBuilder. A complete example is as follows:
Dim sbA As New System.Text.StringBuilder
SbA.AppendLine ("this is a StringWriter
Example of writing to StringBuilder: ")
'The data of this StringWriter is written to the specified StringBuilder
Dim swA As New System.IO.StringWriter (sbA)
Dim arrStr () As String = {"Northsnow"
"Snow in Saibei"}
SwA.WriteLine (arrStr (0))
SwA.WriteLine (arrStr (1))
SwA.WriteLine (String.Format ("{0}-{1}-{2}")
ArrStr (2), arrStr (3), arrStr (4))
Me.TextBox1.AppendText (Environment.NewLine)
Me.TextBox1.AppendText (swA.ToString)
Me.TextBox1.AppendText (Environment.NewLine)
'you can use the GetStringBuilder of StringWriter
Method returns a StringBuilder
Dim sbB As System.Text.StringBuilder =
SwA.GetStringBuilder ()
SbB.AppendLine ("in the returned StringBuilder
Add a row in ")
Me.TextBox1.AppendText (Environment.NewLine)
Me.TextBox1.AppendText (sbB.ToString)
SwA.Close () 'attention, here will be VB.NET StringWriter
Closed, but you can still use StringBuilder later
SbA.AppendLine ("in StringBuilder
Add a new line in ")
Me.TextBox1.AppendText (sbA.ToString)
The result returned by this example is:
This is an example of writing VB.NET StringWriter to StringBuilder:
Snow in the north of Northsnow
A careful friend may have found out. SbA and sbB are the same StringBuilder. That is, sbA and sbB influence each other. For one of the operations, the other also changes. What's going on?
In fact, they are a quote at this time. That is, the StringBuilder object returned through GetStringBuilder is actually a reference to the original StringBuilder object.
The above is all the content of this article "what's the use of VB.NET StringWriter?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.