/ Published in: C#
StringBuilder class is a much better way to concatenate strings. Unlike a string object it can be changed as needed, and is much more efficient than using +=
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// This example concatenates using StringBuilder object then writes contents of the // StringBuilder object out to a file using streamwriter string newLine; for(int i = 0; i < 50; i++) { newLine = "Line # " + i; textSB.Append(newLine).Append("|").Append("\r\n"); } string filePath = @"c:\output.txt"; outFile.Write(textSB.ToString());