转换为字符串,删除一些部分并转换回byte []

Max*_*Max 1 c# string bytearray filter

我需要删除转换为字符串的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);
Run Code Online (Sandbox Code Playgroud)

如何减去前4个句子?

提前致谢!

I4V*_*I4V 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);
Run Code Online (Sandbox Code Playgroud)