It’s very common to split a string into lines. You can write something like that:
var str = “Nickname: meziantou\r\nName: Gérald Barré”;
var lines = str.Split(new [] { ‘\r’, ‘\n’ }, StringSplitOptions.RemoveEmptyEntries);
foreach (var line in lines)
{
// - Allocate 1 string per line + 1 array
// - The Split method may allocate
}

This code create one string per line and allocate one array. So,…

#.net #programming

Split a string into lines without any allocation
1.35 GEEK