*** Now with the option of automatic string concatenation or automatic Stringbuilder code generation ***

Wouldn't it be great to just paste your massive SQL query or other large block of text somewhere and then have a concatenated string or StringBuilder object magically form around it? (Answer: Yes it would be) Now you can automatically create concatenated strings and automatically create StringBuilder objects. BuildMyString.com will take whatever text you input, escape your double quotes, escape your backslashes, and output the results. If you find an issue or want to offer a change or enhancement idea, note it in the comments.

If you're using IE and this page is broken, see this to fix it. It's typically one of the first two issues.

Target object:
String (concatenation)
Stringbuilder
Target language
C#
Java
VB.NET
C++
Preserve blank lines in input as output? Huh?
Variable name (25 max) Huh?
Options
None
Include a <br> at the end of each line Huh?
Include \r\n at the end of each line Huh?
Include a space at the end of each line Huh?
Include this at the end of each line (25 max) Huh?
Handle Tabs
Ignore Tabs Huh?
Strip out any Tabs Huh?
Replace Tabs with \t or vbTAB Huh?
Replace Tabs with a space Huh?
MS specific Options
None
Use AppendLine instead of Append for the Stringbuilder object Huh?
VB only - include " & vbCrLF &" at the end of each line, OUTSIDE of the string Huh?

Enter text

Close (X)
Sometimes, as may be the case with code or a SQL query, you may want to preserve blank lines in your string or Stringbuilder code for readability purposes:
// Sample code follows

for(int i=0; i<5; i++)
{
Console.WriteLine("Current Count: " + i.ToString());
}

Console.WriteLine("Final Count: " + i.ToString());
Checking this box will preserve your blank lines in the output:
StringBuilder sb = new StringBuilder();

sb.Append("// Sample code follows");
sb.Append("");
sb.Append("for(int i=0; i<5; i++) ");
sb.Append(" {");
sb.Append(" Console.WriteLine(\"Current Count: \" + i.ToString());");
sb.Append(" }");
sb.Append("");
sb.Append("Console.WriteLine(\"Final Count: \" + i.ToString());");
Or, leave this box unchecked and blank lines in the input will not be included in the output:
StringBuilder sb = new StringBuilder();

sb.Append("// Sample code follows");
sb.Append("for(int i=0; i<5; i++) ");
sb.Append(" {");
sb.Append(" Console.WriteLine(\"Current Count: \" + i.ToString());");
sb.Append(" }");
sb.Append("Console.WriteLine(\"Final Count: \" + i.ToString());");
Note that if you select the option to preserve blank lines AND any of the options that include additional characters at the end of each line, the output will append these characters to your blank lines as well.
Close (X)
Close (X)
By default, the output will use the name of "sb" for your variable. Feel free to change it to anything you prefer:
StringBuilder greatestObjectEver = new StringBuilder();
Close (X)
Close (X)
If you're outputting text to an HTML doc, you can select this option to have a <br> appended at the end of each line of the input:
StringBuilder sb = new StringBuilder();

sb.append("Four score and seven years ago<br>");
sb.append("our fathers brought forth on this continent,<br>");
sb.append("a new nation, conceived in Liberty,<br>");
sb.append("and dedicated to the proposition that<br>");
sb.append("all men are created equal.<br>");
Close (X)
Close (X)
When inputting multiple lines of text, you might be expecting the words to seperate properly at the line breaks:
Four score and seven years ago
our fathers brought forth on this continent,
a new nation, conceived in Liberty,
and dedicated to the proposition that
all men are created equal.
However, most multi line text will terminate right after the last character of the line creating an unexpected result in the output:
StringBuilder sb = new StringBuilder();

sb.Append("Four score and seven years ago");
sb.Append("our fathers brought forth on this continent,");
sb.Append("a new nation, conceived in Liberty,");
sb.Append("and dedicated to the proposition that");
sb.Append("all men are created equal.");

OUTPUT: Four score and seven years agoour fathers brought forth....
By checking this box, a space will be appended to the end of each line:
StringBuilder sb = new StringBuilder();

sb.Append("Four score and seven years ago ");
sb.Append("our fathers brought forth on this continent, ");
sb.Append("a new nation, conceived in Liberty, ");
sb.Append("and dedicated to the proposition that ");
sb.Append("all men are created equal. ");

OUTPUT: Four score and seven years ago our fathers brought forth....
Close (X)
Close (X)
You may need to append something custom to the end of each line. You can enter a custom suffix here. (Note if you use a custom suffix, it will NOT be escaped, you must do that yourself.)
Text::StringBuilder^ sb = gcnew Text::StringBuilder;

sb->Append("Four score and seven years ago\n");
sb->Append("our fathers brought forth on this continent,\n");
sb->Append("a new nation, conceived in Liberty,\n");
sb->Append("and dedicated to the proposition that\n");
sb->Append("all men are created equal.\n");
Close (X)
Close (X)
For C#, VB.NET, and C++, select this option to use AppendLine instead of Append for the Stringbuilder object. AppendLine will add the default line terminator to the end of each line: (This option has no effect if the target object is a concatenated string or if the target language is Java)
sb.AppendLine("Four score and seven years ago");
sb.AppendLine("our fathers brought forth on this continent,");

OUTPUT: Four score and seven years ago
our fathers brought forth on this continent,
Close (X)
Close (X)
For a VB.NET concatenated string only, selecting this option will append the VB carriage return constant at the end of each line of the string. This option only applies if VB.NET is the target language and the target object is a concatenated string.
Dim sb As String
sb = "Four score and seven years ago" & vbCrLf &
"our fathers brought forth on this continent," & vbCrLf &
"a new nation, conceived in Liberty"

OUTPUT: Four score and seven years ago
our fathers brought forth on this continent,
a new nation, conceived in Liberty
Close (X)
Close (X)
Tabs can display unpredictably unless they are handled. If you are certain your source text has no Tabs, this option is fine. Otherwise, use one of the options below.
Close (X)
Close (X)
Strip out any Tabs that are found in the source text. This can be useful to remove unwanted Tabs, but keep in mind anything seperated by a Tab in the source text will no longer be seperated in the output:
Source Text (separated by Tabs): Column1 Column2 Column3

OUTPUT: Column1Column2Column3
Close (X)
Close (X)
Replace any Tabs found with \t or, if VB.Net is selected, vbTAB. If there are Tabs in your source text that you wish to preserve, this is the option.
Source Text (separated by Tabs):
Col1 Col2
Data1 Data2
Data1 Data2

OUTPUT:
Dim sb As String
sb = "Col1" + vbTab + "Col2" & vbCrLf &
"Data1" + vbTab + "Data2" & vbCrLf &
"Data1" + vbTab + "Data2"
Close (X)
Close (X)
Replace any Tabs found with a space. This can be useful for formatting source text that is Tab delimited or copied from a spreadsheet:
Source Text (separated by Tabs):
Col1 Col2
Data1 Data2
Data1 Data2

OUTPUT:
string sb = "Col1 Col2\r\n" +
"Data1 Data2\r\n" +
"Data1 Data2\r\n";
Close (X)
Close (X)
If you're outputting text that's not HTML, you can select this option to have \r\n appended at the end of each line of the input.
(This is ignored for VB.Net. There is an option below to append vbCrLF.)
StringBuilder sb = new StringBuilder();

sb.append("Four score and seven years ago\r\n");
sb.append("our fathers brought forth on this continent,\r\n");
sb.append("a new nation, conceived in Liberty,\r\n");
sb.append("and dedicated to the proposition that\r\n");
sb.append("all men are created equal.\r\n");
Close (X)
comments powered by Disqus