CSharp examples for System:Byte Array
Pad Right byte array
using System.Text; using System;//from w ww.j a v a 2s. c o m public class Main{ public static byte[] PadRight(this byte[] data, byte b, int count) { var offset = data.Length; data = data.SkipAndTake(0, data.Length + count, true); for (var i = offset; i < data.Length; i++) { data[i] = b; } return data; } public static byte[] SkipAndTake(this byte[] array, int skip, int take, bool extend = false) { if (!extend && take > array.Length) { take = array.Length; } byte[] result = new byte[take]; if (extend && take > array.Length) { take = array.Length; } if (take == 0) { return result; } if (skip == 0) { Array.Copy(array, result, take); } else { Array.Copy(array, skip, result, 0, take); } return result; } }