Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting value from Binary field
Message
From
28/01/2014 04:27:27
 
 
To
28/01/2014 00:37:30
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01592445
Message ID:
01592478
Views:
47
This message has been marked as a message which has helped to the initial question of the thread.
>>>
>>>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);
        }
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform