我需要删除转换为字符串的byte []的前4个句子。
到目前为止我所拥有的:
//convert bytearray to string, so I can modify the string
string rawString = Convert.ToBase64String(rawByteArray);
//seperate lines
string[] textLines = Regex.Split(rawString, "\r\n");
//I need to substract the first 4 senctences of the string here!
//convert string back to byte array
byte[] cleanByteArray = rawstring.FromBase64String(rawString);
如何减去前4个句子?
提前致谢!
答案 0 :(得分:6)
您要找的是Encoding.GetString
而不是Base64字符串。
var newstr = String.Join(Environment.NewLine, Encoding.UTF8.GetString(buf)
.Split(new char[] { '\n', '\r' })
.Skip(4));
buf = Encoding.UTF8.GetBytes(newstr);