Here there is a code snippet showing how to left pad an array (in this case, a byte array).

public static byte[] ByteArrayLeftPad(byte[] input, byte padValue, int len)
{
    var temp = Enumerable.Repeat(padValue, len).ToArray(); ;
    var startAt = temp.Length - input.Length;
    Array.Copy(input, 0, temp, startAt, input.Length);
    return temp;
}
Advertisements