Possible Duplicate:
Easiest way to split a string on newlines in .net?
I'm trying to read out and interpret a string line per line. I took a look at the StringReader class, but I need to find out when I'm on the last line. Here's some pseudocode of what I'm trying to accomplish:
while (!stringReaderObject.atEndOfStream()) {
interpret(stringReaderObject.readLine());
}
Does somebody know how to do this?
Thanks!
Yvan
private static IEnumerable<string> ReadAllLines(string multiLineString) { if (string.IsNullOrEmpty(multiLineString)) yield break; // Nothing to do using (var reader = new StringReader(multiLineString)) { string line; while ((line = reader.ReadLine()) is object) { yield return line; } } }