lamp

Multi Line string in C#

Published 02 February 10 10:57 AM | Frederick.Chapleau

Ever wonder of a more efficient way to write multiple lines strings?

Check this out…

The first way...

string myString1 = "This is the first line of my string.\n" +
                   "This is the second line of my string.\n" +
                   "This is the third line of the string.\n";
And a more efficient way...

string myString2 = @"This is the first line of my string.
This is the second line of my string.
This is the third line of the string.";

-f.

Filed under:

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Protected by FormShield
Refresh
Listen
Please enter the characters shown on the image


Code: