Remove last line from a string

Viewed 18454

I have a string that could look like this:

line1
line2
line3
line4

and I want to remove the last line (line4). How would I do this?

I attempted something like this but it requies that I know how many characters the last line contains:

output = output.Remove(output.Length - 1, 1)
6 Answers
Related