>>>
>>>Since the size of the hex presentation is twice the size of the byte array, you have to multiply by 2
>>>
>>>>> StringBuilder sb = new StringBuilder(length * 2);
>>>
>>>
>>>
>>>The bitshift: shifting one bit to the left (provided the argument is not negative) is faster. I prefer that
>>>
>>>
>>>>> StringBuilder sb = new StringBuilder(length << 1);
>>>
>>
>>Cute :-)
>
>Another thing I have found
>
>(1) You have class with an array member ( I tested static, expect instance also)
>(2) A method using that array frequently ( a loop or so)
>
>It is faster to assign the array to a method variable and use the method variable instead of the class member
Interesting. But how about:
static string ToHex(byte[] bytes)
{
return "0X"+ BitConverter.ToString(bytes).Replace("-",string.Empty);
}