public static byte[] Fill(this byte[] source, int offset, int size, byte content) { //Create filler array of byte var filler = new byte[size]; for (var i = 0; i < size; i++) { filler[i] = content; } //Verify wrhere put filler array var splitIndex = offset - 1; if (splitIndex == 0) { //Fill content array at the start of source array return(ByteArrayOperations.Combine(filler, source)); } else if (splitIndex == source.Length - 1) { //Fill content array at the end of source array return(ByteArrayOperations.Combine(source, filler)); } else { //Fill the array at offset position that is not start nor end of source array throw new NotImplementedException("Not supported yet"); } }
public static byte[] Combine(this byte[] source, byte[] data) { if (source == null) { return(data); } return(ByteArrayOperations.Combine(source, data)); }