I have a array byte[]. It contains the lines of a string[], seperated with line breaks. What would the best way to get the string[] back from the byte[]? Encoding is utf-8.
byte[] lines[];
string[] str = Encoding.UTF8.GetString(lines).Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
Would be an option, but maybe there is a better way.
using (var ms = new MemoryStream(lines)) { using (var sr = new StreamReader(ms, Encoding.UTF8)) { string line; while ((line = sr.ReadLine()) != null) { // ... } } }. Very curious to find an easier way.