Template:Csharp strings
Strings
Strings are an object in c#
String concatenation
+ is also used to concatenate strings
If you have two string that you want to combine into one string you can concatenate them. Or use the super jedi .net method String.Format method
<csharp>//Create a string and set it's value to "cool."
string coolString = "cool";
//Do some concatenations and make it super cool
Console.WriteLine ("Super " + "string " + "theory!!!\n" + "Is really " + coolString + ".");
string notherCoolString = "another " + coolString + " string."; Console.WriteLine(notherCoolString);
Console.WriteLine(String.Format("In Line formating of '{0}'", notherCoolString));
</csharp>
will output (remember \n is a new line)
Super string theory!!!! Is really cool. another cool string. In Line formating of 'another cool string.'
Escape Sequences
The backslash character is used as a string escape sequence. It will escape the next character and change it's meaning. For example \" with output a ", \n with out put a newline and \\ with output a single \.