What is the best way to replace some bytes in a byte array??
For instance i have bytesFromServer = listener.Receive(ref groupEP); and i can do BitConverter.ToString(bytesFromServer) to convert it into a readable format to return something along the lines of
48 65 6c 6c 6f 20
74 68 65 72 65 20
68 65 6c 70 66 75
6c 20 70 65 6f 70
6c 65
I would like to replace something inside of that making “68 65 6c” to something like “68 00 00” (just as an example). There is not .Replace() on a byte[].
Would there be an easy way to convert that back into a byte[]?
Any help appreciated. Thank you!
You could program it…. try this for a start… this is however not robust not production like code yet…beaware of off-by-one errors I didn’t fully test this…
Implement as an extension method
usage normal method:
Extension method usage: