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.
String.Split can split your string and give you string[]
Usage
string someString = ...;
string[] lines = someString.Split('\n');
IEnumerable<string> linesAsEnumerable = lines;
DoSomethingWithLines(linesAsEnumerable);
IEnumerable<string> lines = someString.Split(Environment.NewLine);.Split(Environment.NewLine, StringSplitOptions.None) because Environment.NewLine is a string and there is no override of Split that just takes a single string argument.string[] variable to show actual return type. IEnumerable<string> slower to process than raw array
"someString".Split('\n')?.Split(Environment.NewLine, StringSplitOptions.None)would be a better choice.Environment.NewLine?StringReaderdoes