I need to convert string
to IEnumerable<string>
by every newline character.
I just want the same functionality as File.ReadLines
without loading any file, rather taking it from a previously loaded string.
I need to convert string
to IEnumerable<string>
by every newline character.
I just want the same functionality as File.ReadLines
without loading any file, rather taking it from a previously loaded string.
You could split it according to the newline character:
String[] lines = fileContenets.Split('\n');
String.Split can split your string and give you string[]
Usage
string someString = ...;
string[] lines = someString.Split('\n');
IEnumerable<string> linesAsEnumerable = lines;
DoSomethingWithLines(linesAsEnumerable);