tagged [stringbuilder]

Remove last character of a StringBuilder?

Remove last character of a StringBuilder? When you have to loop through a collection and make a string of each data separated by a delimiter, you always end up with an extra delimiter at the end, e.g....

10 Jul at 17:32

How to append a newline to StringBuilder

How to append a newline to StringBuilder I have a [StringBuilder](http://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html) object, Now I want to append a newline character to the `String...

11 Aug at 16:41

StringBuilder vs String concatenation in toString() in Java

StringBuilder vs String concatenation in toString() in Java Given the 2 `toString()` implementations below, which one is preferred: or ``` public String toString(){ StringBuilder sb = new StringBuil...

.NET StringBuilder preappend a line

.NET StringBuilder preappend a line I know that the `System.Text.StringBuilder` in .NET has an `AppendLine()` method, however, I need to pre-append a line to the beginning of a `StringBuilder`. I know...

18 Feb at 17:44

Equivalent of StringBuilder for byte arrays

Equivalent of StringBuilder for byte arrays This is a simple one, and one that I thought would have been answered. I did try to find an answer on here, but didn't come up with anything - so apologies ...

25 Oct at 14:36

How to remove empty lines from a formatted string

How to remove empty lines from a formatted string How can I remove empty lines in a string in C#? I am generating some text files in C# (Windows Forms) and for some reason there are some empty lines. ...

17 May at 15:56

Is it required to check before replacing a string in StringBuilder (using functions like "Contains" or "IndexOf")?

Is it required to check before replacing a string in StringBuilder (using functions like "Contains" or "IndexOf")? Is there any method IndexOf or Contains in C#. Below is the code: ``` var sb = new St...

14 Jul at 08:39

What does ----s mean in the context of StringBuilder.ToString()?

What does ----s mean in the context of StringBuilder.ToString()? The [Reference Source page for stringbuilder.cs](http://referencesource.microsoft.com/#mscorlib/system/text/stringbuilder.cs,5a97da49a1...

Read all ini file values with GetPrivateProfileString

Read all ini file values with GetPrivateProfileString I need a way to read all sections/keys of ini file in a StringBuilder variable: ``` [DllImport("kernel32.dll")] private static extern int GetPriva...

17 Aug at 08:48

.NET StringBuilder - check if ends with string

.NET StringBuilder - check if ends with string What is the best (shortest and fastest) way to check if `StringBuilder` ends with specific string? If I want to check just one char, that's not a problem...

10 Jul at 20:28

C# Differences between operator ==, StringBuilder.Equals, Object.Equals and Object.ReferenceEquals

C# Differences between operator ==, StringBuilder.Equals, Object.Equals and Object.ReferenceEquals I have a question about `Object.Equals` and `Equals(object)`. My sample code is below: ``` class Prog...

Problem with StringBuilder and XML Literals

Problem with StringBuilder and XML Literals I'm having a problem using XML literals with a StringBuilder in VB 2008. If I use this code everything is fine. Now the problem is I want to wrap HTML aroun...

Runtime error in StringBuilder instance

Runtime error in StringBuilder instance Please, help me understand, what's wrong with this code. (I am trying to build a string, taking parts of it line by line from a text file). I get a runtime erro...

2 Mar at 14:54

How can I clear or empty a StringBuilder?

How can I clear or empty a StringBuilder? I'm using a [StringBuilder](http://download.oracle.com/javase/1.5.0/docs/api/java/lang/StringBuilder.html) in a loop and every x iterations I want to empty it...

8 Feb at 01:15

Why does the WPF Presentation library wrap strings in StringBuilder.ToString()?

Why does the WPF Presentation library wrap strings in StringBuilder.ToString()? The code found in the `PresentationCore.dll` (.NET4 WPF) by : ``` // MS.Internal.PresentationCore.BindUriHelper internal...

31 Jan at 12:19

Correct way to use StringBuilder in SQL

Correct way to use StringBuilder in SQL I just found some sql query build like this in my project: Does this `StringBuilder` achieve its aim, i.e reducing memory usage? I doubt that, because in the co...

19 Dec at 19:49

Is there any scenario where the Rope data structure is more efficient than a string builder

Is there any scenario where the Rope data structure is more efficient than a string builder > Related to [this question](https://stackoverflow.com/questions/1862703/public-implementation-of-ropes-in-c...

23 May at 12:34

What is the use of the return value of the StringBuilder Append(string...) function?

What is the use of the return value of the StringBuilder Append(string...) function? The complete syntax of StringBuilder's Append(string s) function (and similar functions) is since `myStringBuilder....

15 Feb at 10:13

StringBuilder Vs StringWriter/StringReader

StringBuilder Vs StringWriter/StringReader I recently read that in `StringWriter` and `StringReader` are used for writing and reading from `StringBuilder`. Well when I use `StringBuilder` Object, it l...

String or StringBuilder return values?

String or StringBuilder return values? If I am building a string using a StringBuilder object in a method, would it make sense to: Return the StringBuilder object, and let the calling code call ToStri...

Forcing StreamWriter to change Encoding

Forcing StreamWriter to change Encoding I am trying to save a file using `DialogResult` and `StringBuilder`. After making the text, I am calling the following code to save the file: I tried to add the...

16 Nov at 12:9

When do you use StringBuilder.AppendLine/string.Format vs. StringBuilder.AppendFormat?

When do you use StringBuilder.AppendLine/string.Format vs. StringBuilder.AppendFormat? A recent [question came up](https://stackoverflow.com/questions/349659/stringformat-or-not) about using String.Fo...

23 May at 12:26

Most efficient solution for reading CLOB to String, and String to CLOB in Java?

Most efficient solution for reading CLOB to String, and String to CLOB in Java? I have a big CLOB (more than 32kB) that I want to read to a String, using StringBuilder. How do I do this in the most ef...

30 Jan at 22:58

Is String.Format as efficient as StringBuilder

Is String.Format as efficient as StringBuilder Suppose I have a stringbuilder in C# that does this: would that be as efficient or any more efficient as having: If so, why

StringBuilder Class OutOfMemoryException

StringBuilder Class OutOfMemoryException I have written following function ``` public void TestSB() { string str = "The quick brown fox jumps over the lazy dog."; StringBuilder sb = new StringBuilde...

30 May at 01:26