Reputation: 771
I'm trying to initialize a string variable with a large text with 50+ lines. But the string variable isn't taking the anything after the second line. I tried using StringBuilder, which failed as well.
string longText = "";
sample text:
foo bar foo bar bar
bar bar bar foo foo tigerlime orange lemon bar bar
...etc ..
There's not quotes in the text, simply has new lines. I could regex and replace the newlines with some special character, but that feels like over engineering it. Any simple method I'm missing out??
Upvotes: 3
Views: 1836
Reputation: 3871
Use the @ string literal before the string assignment:
string a = @"
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
est laborum.";
Upvotes: 5
Reputation: 1433
string longText = @"
sample text:
foo bar foo bar bar
bar bar bar foo foo tiger
lime orange lemon bar bar
etc
etc .. ";
Upvotes: 0