Click here to Skip to main content
16,011,428 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# coding Pin
Richard MacCutchan7-Aug-11 21:52
mveRichard MacCutchan7-Aug-11 21:52 
AnswerRe: C# coding Pin
BobJanova7-Aug-11 23:14
BobJanova7-Aug-11 23:14 
AnswerRe: C# coding Pin
#realJSOP8-Aug-11 1:49
professional#realJSOP8-Aug-11 1:49 
GeneralRe: C# coding Pin
Not Active8-Aug-11 1:53
mentorNot Active8-Aug-11 1:53 
AnswerRe: C# coding Pin
V.8-Aug-11 2:16
professionalV.8-Aug-11 2:16 
AnswerRe: C# coding Pin
PIEBALDconsult8-Aug-11 2:48
mvePIEBALDconsult8-Aug-11 2:48 
QuestionHow do I store two int values into one DWORD, and then convert it to a 4 byte array? Pin
stephen.darling7-Aug-11 11:04
stephen.darling7-Aug-11 11:04 
AnswerRe: How do I store two int values into one DWORD, and then convert it to a 4 byte array? Pin
PIEBALDconsult7-Aug-11 13:44
mvePIEBALDconsult7-Aug-11 13:44 
I still don't see why you insist on the array of bytes.

Here's a rather simple way without unsafe code:

uint a = 396 ;
uint b = 398565 ;

uint c = ( a << 20 ) | ( b & 0x0FFFFFu ) ;

byte[] d = new byte [ sizeof(uint) ] ;

for ( int i = 0 ; i < d.Length ; i++ )
{
    d [ i ] = (byte ) ( ( c >> 8 * i ) & 0x0FF ) ;
}

uint e = 0 ;

for ( int i = 0 ; i < d.Length ; i++ )
{
    e |= (uint) ( d [ i ] << 8 * i ) ;
}

uint f = e >> 20 ;
uint g = e & 0x0FFFFFu ;

AnswerRe: How do I store two int values into one DWORD, and then convert it to a 4 byte array? Pin
Luc Pattyn7-Aug-11 15:32
sitebuilderLuc Pattyn7-Aug-11 15:32 
GeneralRe: How do I store two int values into one DWORD, and then convert it to a 4 byte array? Pin
PIEBALDconsult7-Aug-11 18:02
mvePIEBALDconsult7-Aug-11 18:02 
GeneralRe: How do I store two int values into one DWORD, and then convert it to a 4 byte array? Pin
stephen.darling8-Aug-11 4:48
stephen.darling8-Aug-11 4:48 
GeneralRe: How do I store two int values into one DWORD, and then convert it to a 4 byte array? Pin
PIEBALDconsult8-Aug-11 16:37
mvePIEBALDconsult8-Aug-11 16:37 
GeneralRe: How do I store two int values into one DWORD, and then convert it to a 4 byte array? Pin
stephen.darling8-Aug-11 5:08
stephen.darling8-Aug-11 5:08 
GeneralRe: How do I store two int values into one DWORD, and then convert it to a 4 byte array? Pin
PIEBALDconsult8-Aug-11 15:31
mvePIEBALDconsult8-Aug-11 15:31 
AnswerRe: How do I store two int values into one DWORD, and then convert it to a 4 byte array? Pin
BobJanova7-Aug-11 23:12
BobJanova7-Aug-11 23:12 
GeneralRe: How do I store two int values into one DWORD, and then convert it to a 4 byte array? Pin
stephen.darling8-Aug-11 4:45
stephen.darling8-Aug-11 4:45 
GeneralRe: How do I store two int values into one DWORD, and then convert it to a 4 byte array? Pin
stephen.darling8-Aug-11 5:28
stephen.darling8-Aug-11 5:28 
GeneralRe: How do I store two int values into one DWORD, and then convert it to a 4 byte array? Pin
BobJanova8-Aug-11 7:30
BobJanova8-Aug-11 7:30 
AnswerRe: How do I store two int values into one DWORD, and then convert it to a 4 byte array? Pin
Matt Meyer8-Aug-11 6:55
Matt Meyer8-Aug-11 6:55 
GeneralRe: How do I store two int values into one DWORD, and then convert it to a 4 byte array? Pin
stephen.darling8-Aug-11 7:38
stephen.darling8-Aug-11 7:38 
QuestionIs this the same? Pin
stephen.darling7-Aug-11 10:07
stephen.darling7-Aug-11 10:07 
AnswerRe: Is this the same? Pin
PIEBALDconsult7-Aug-11 10:20
mvePIEBALDconsult7-Aug-11 10:20 
GeneralRe: Is this the same? Pin
stephen.darling7-Aug-11 10:33
stephen.darling7-Aug-11 10:33 
GeneralRe: Is this the same? Pin
BobJanova7-Aug-11 23:10
BobJanova7-Aug-11 23:10 
GeneralRe: Is this the same? Pin
stephen.darling8-Aug-11 4:44
stephen.darling8-Aug-11 4:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.