I'll just mention here that these samples of code are exactly equivalent in speed terms...

1.
Code:
        if((val & mask) != 0) 
            *index =  (sbyte)0x31; 
        else 
            *index =  (sbyte)0x30;
2.
Code:
        *index = (val & mask) != 0 ? (sbyte)0x31 : (sbyte)0x30;
I used the first because its easier to read but otherwise the performance is identical and I think they probably compile to the same IL code anyway.

I mention this because of the common misconception (stemming from VB6) that inline ?: operators are slower than if() else blocks. In C# this is not true, as demonstrated above, but in VB6 an IIf() was substancially slower than an if...end if block.

Just FYI