StringBuilder 
Author Message
 StringBuilder

Hi, how can I reset the StringBuilder object without further initialization
? It's correct to use the Length method ?
Thank. Paolo

StringBuilder LocSql = new StringBuilder("");

LocSql.Append("Hello !");
LocSql.Length = 0;

LocSql.Append("Hallo!");
LocSql.Length = 0;



Sun, 31 Oct 2004 22:46:47 GMT  
 StringBuilder
yes, it correct


Sun, 31 Oct 2004 23:03:08 GMT  
 StringBuilder
You can reset the string by using this function:

LocSql.Remove(0, LocSql.Length);

This will pretty much "reset" your string.
I tested the LocSql.Length = 0; and it seems to work, honestly I dont know how it effects the memory, but the .Net framework manages the memory so who
knows.  So I prefer the Remove method since that is what it is supposed to be used for.

Hope this helps,
Dat Bui
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.  ? Microsoft Corporation.  All rights reserved.

--------------------

Quote:

>Subject: StringBuilder
>Date: Wed, 15 May 2002 16:46:47 +0200
>Lines: 13
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

>Newsgroups: microsoft.public.dotnet.languages.CSharp
>NNTP-Posting-Host: 213.82.54.94
>Path: cpmsftngxa07!INTERNETBUILD41!tkmsftngp01!tkmsftngp02
>Xref: cpmsftngxa07 microsoft.public.dotnet.languages.csharp:61228
>X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

>Hi, how can I reset the StringBuilder object without further initialization
>? It's correct to use the Length method ?
>Thank. Paolo

>StringBuilder LocSql = new StringBuilder("");

>LocSql.Append("Hello !");
>LocSql.Length = 0;

>LocSql.Append("Hallo!");
>LocSql.Length = 0;



Tue, 02 Nov 2004 05:45:59 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. StringBuilder!

2. StringBuilder Replace vs Append Speed

3. help: textBox vs. StringBuilder in a callback function

4. System::String/StringBuilder as out parameter

5. StringBuilder.AppendFormat parameters

6. String functions or using Regular Expressions or StringBuilder

7. StringBuilder and null char - ToString issue

8. Behavior with StringBuilder

9. StringBuilder vs. String.Concat

10. DLLImport & StringBuilder

11. StringBuilder / String problem creating MQ path name

12. StringBuilder vs String

 

 
Powered by phpBB® Forum Software