Home All Groups Group Topic Archive Search About
Author
6 Jan 2006 12:20 AM
JK
How would I convert something like below to c# or VB.Net.

    unsigned char ar[] = "AB";
    unsigned int i = 0;
    i = *(unsigned int *)ar;

Thanks
JK

Author
6 Jan 2006 1:53 AM
Mattias Sjögren
>How would I convert something like below to c# or VB.Net.
>
>    unsigned char ar[] = "AB";
>    unsigned int i = 0;
>    i = *(unsigned int *)ar;

Well if it's the end result you want then you can simply do

Dim i As Integer = &H4241

As a bonus you get rid of the bug in the original code, which is a
perfect example of how you can shoot yourself in the foot if you don't
use pointers carefully.


Mattias

--
Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.