المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How do I store two int values into one DWORD, and then convert it to a 4 byte array?



C# Programming
08-08-2011, 02:00 AM
Hi.

Please consider the following fixed values...

unsigned int value1 = 396;unsigned int value2 = 398565;

1) The above values will change, but value1 will always be 3 digits, and value2 will always be 6 digits.

How do I....

A) Place both values into one DWORD?

b) Encode it as a 4 byte array.

So, as an example (not actual values)

396 + 398565 -> (DWORD) = 396398565 -> BYTE[] = {0x00, 0x00, 0x00, 0x00 } (whatever the hex would be)
And then, I would need to reverse it, although I think I have the code working to do that, but cant test it properly until I can get the above to work.

Thank you,
Steve