Multiline string with added text from variables

One option is to use string formatting instead. Before C# 6:

string pattern = @"this is a multiline text
this is {0}
this is {1}
this is {2}";

string result = string.Format(pattern, a1, a2, a3);

With C# 6, you can use an interpolated verbatim string literal:

string pattern = $@"this is a multiline text
this is {a1}
this is {a2}
this is {a3}";

Note that $@ has to be exactly that – if you try to use @$, it won’t compile.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)