M
mp
Hi,
according to help
(http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.aspx)
there's a .Clear method on the string builder object to empty the contents.
I don't get that in my ide.
StringBuilder lastLine = new StringBuilder();
....fill in lastLine then try to clear it...
lastLine.Clear();
....produces this error
Error 1 'System.Text.StringBuilder' does not contain a definition for
'Clear' and no extension method 'Clear' accepting a first argument of type
'System.Text.StringBuilder' could be found (are you missing a using
directive or an assembly reference?)
if there's not a .Clear method, how to empty and reuse a StringBuilder?
I have a loop and I fill a StringBuilder via .Append,
then i read it at some point(via .ToString()),
then want to clear it and start a new one...
can I just create a new reference? and does that automatically "discard" the
previous reference?
StringBuilder lastLine = new StringBuilder();
....using in some loop...
do {
lastLine.Append ("something");
//at some point i'm done with this one
//do something with lastLine.ToString();
//now i want a new blank stringBuilder...do i just re-create one?
lastLine = new StringBuilder();
//or should i empty the existing one?
lastLine.Remove(0, lastLine.Length - 1);
....continue processing...
} (until Done![Wink ;) ;)](/styles/default/custom/smilies/wink.gif)
thanks
mark
according to help
(http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.aspx)
there's a .Clear method on the string builder object to empty the contents.
I don't get that in my ide.
StringBuilder lastLine = new StringBuilder();
....fill in lastLine then try to clear it...
lastLine.Clear();
....produces this error
Error 1 'System.Text.StringBuilder' does not contain a definition for
'Clear' and no extension method 'Clear' accepting a first argument of type
'System.Text.StringBuilder' could be found (are you missing a using
directive or an assembly reference?)
if there's not a .Clear method, how to empty and reuse a StringBuilder?
I have a loop and I fill a StringBuilder via .Append,
then i read it at some point(via .ToString()),
then want to clear it and start a new one...
can I just create a new reference? and does that automatically "discard" the
previous reference?
StringBuilder lastLine = new StringBuilder();
....using in some loop...
do {
lastLine.Append ("something");
//at some point i'm done with this one
//do something with lastLine.ToString();
//now i want a new blank stringBuilder...do i just re-create one?
lastLine = new StringBuilder();
//or should i empty the existing one?
lastLine.Remove(0, lastLine.Length - 1);
....continue processing...
} (until Done
![Wink ;) ;)](/styles/default/custom/smilies/wink.gif)
thanks
mark