I'm trying to use linq where it makes my code readable - foreach loops generally being easy targets.
Yet there's one that seems simple but yet the linq form escapes me:
const byte EscapeByte = 0x5C;
List<byte> result = new List<byte>();
foreach (var v in values)
{
if (v.Escaped)
{
result.Add(EscapeByte);
}
result.Add(v.DataByte);
}
return result.ToArray();
Which probably means it's best left alone.. yet I am curious if a veteran could linq it in a readable way?