开发者

What is the appropriate way to set a VB StringBuilder to an empty string?

开发者 https://www.devze.com 2022-12-30 16:58 出处:网络
I\'m using VB\'s StringBuilder, and I was curious what is considered \"best practice\" for emptying the builder/setting it to a new string. Would it be something like this:

I'm using VB's StringBuilder, and I was curious what is considered "best practice" for emptying the builder/setting it to a new string. Would it be something like this:

Dim str As New System.Text.StringBuilder(开发者_如何学运维)
str.Append("Some string to remove")
str = new System.Text.StringBuilder()
str.Append("Ahh, fresh new text!")

or is there a "Better" way?

Thanks


I usually just use:

str.Length = 0


In .Net 4, they have added a Clear method for that purpose.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号