2

How can I remove a group of elements inside an array?

I have the following code:

private void processResponse(byte[] response)
    {            
        byte[] header;
        byte[] payload;

        if (response.Length > 8)
        {
            header = response.Take<byte>(8).ToArray();
            //payload = //should be the rest of "response" bytes
        }           
    }
}

How can I make payload to be response without header?

0

1 Answer 1

8

You are looking for Skip method:

payload = response.Skip(8).ToArray();
Sign up to request clarification or add additional context in comments.

1 Comment

It is a good solution, but i would also like to remove the "skipped" part from the "main" array. The best of the best would be a method like "String.Substring(..)" that also removes that substring, but for Arrays, or a Linq similar approach. Thanks anyway!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.