Tutorial by Examples

string s1 = "string1"; string s2 = "string2"; string s3 = s1 + s2; // "string1string2"
Concatenating strings using a StringBuilder can offer performance advantages over simple string concatenation using +. This is due to the way memory is allocated. Strings are reallocated with each concatenation, StringBuilders allocate memory in blocks only reallocating when the current block is e...
The String.Join method can be used to concatenate multiple elements from a string array. string[] value = {"apple", "orange", "grape", "pear"}; string separator = ", "; string result = String.Join(separator, value, 1, 2); Console.WriteLine(resu...
$ provides an easy and a concise method to concatenate multiple strings. var str1 = "text1"; var str2 = " "; var str3 = "text3"; string result2 = $"{str1}{str2}{str3}"; //"text1 text3"

Page 1 of 1