In C#, what’s the best way to spread a single-line string literal across multiple source lines?

I would use a variation of your method:

string longString =
    "Lorem ipsum dolor sit amet, consectetur adipisicing " + 
    "elit, sed do eiusmod tempor incididunt ut labore et dolore magna " + 
    "aliqua. Ut enim ad minim veniam.";

Here I start the string on the line after the equals sign so that they all line up, and I also make sure the space occurs at the end of the line (again, for alignment purposes).

Leave a Comment

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