These are methods from FCL that can be used to concatenate strings without using any concatenation operator. The + and + = operators tend to use a large amount of memory for repeated calls (i.e., in a loop) due to the nature of the lines and time lines being created. ( Edit: As pointed out in the comments, String.Format is often not an effective solution)
This is a syntactic alternative rather than sugar.
string full = String.Format("{0}{1}{2}", "prefix", "main string", "last string");
^ More information about String.Format on MSDN .
Edit: For only two lines:
string result = string.Concat("prefix", "last part");
^ More information about String.Concat .
John k
source share