Example #1
0
    /// <summary> Set a specific Byte of the specified packed Int32. </summary>
    public static int BytePackSet(Int32 inValue, WhichByte inByte, byte inSetByteTo)
    {
        ByteArray gb = new ByteArray(inValue);

        switch (inByte)
        {
        case WhichByte.Byte0:
            gb.Byte01 = inSetByteTo;
            break;

        case WhichByte.Byte1:
            gb.Byte02 = inSetByteTo;
            break;

        case WhichByte.Byte2:
            gb.Byte03 = inSetByteTo;
            break;

        case WhichByte.Byte3:
            gb.Byte04 = inSetByteTo;
            break;
        }

        return(gb.bytearray);
    }
Example #2
0
    /// <summary> Get a specific Byte from the packed Int32. </summary>
    public static byte BytePackGet(Int32 inValue, WhichByte inByte = WhichByte.Byte0)
    {
        ByteArray gb = new ByteArray(inValue);

        switch (inByte)
        {
        case WhichByte.Byte0:
            return(gb.Byte01);

        case WhichByte.Byte1:
            return(gb.Byte02);

        case WhichByte.Byte2:
            return(gb.Byte03);

        case WhichByte.Byte3:
            return(gb.Byte04);

        default:
            return(default(byte));
        }
    }