110,571
社区成员
发帖
与我相关
我的任务
分享
Encoding ascii = Encoding.ASCII;
byte[] tm = new byte[] { 94, 1, 2, 3, 94, 122, 24, 4, 5, 94, 3, 4 };
string target = ascii.GetString(tm);
char[] splitter = ascii.GetChars(new byte[] { 94 });
List<byte[]> result1 = new List<byte[]>();
string[] result = target.Split(splitter);
foreach (var str in result)
{
result1.Add(ascii.GetBytes(str));
}
var result = tm.Aggregate(new List<List<byte>>(), (container, x) =>
{
if (container.Count == 0 || x == 94)
container.Add(new List<byte>());
else
container.Last().Add(x);
return container;
})
.Select(lst => lst.ToArray());