Is there a straightforward way to create a string by adding new text as new line?
I want to create a log-style text, for keeping events as so:
Something superb happened
Wow, that is awesome
Look, a super awesome event here
A little event there
Whoops, an error here
What I’ve found is basically.. nothing new
List<string> output = new List<string>();
output.add("Something superb happened");
output.add("Wow, that is awesome");
output.add("Look, a super awesome event here");
output.add("A little event there");
output.add("Whoops, an error here");
string finalOutput = string.Join(Environment.NewLine, output);
Is there a better way?
You can also use StringBuilder. It is pretty efficient.
might be more efficient that what you have if you do it a lot as it doesn’t create lot of temporary strings.