memcpy like function in c#

  • Thread starter Thread starter babylon
  • Start date Start date
B

babylon

i have a byte array
e.g.
byte[] abc = new byte[100];

and i have some integers
e.g.
int height = 166;
int age = 23;

i wanna store them into the byte array abc like "[height 4-byte][age
4-byte]"
i.e.
memcpy(&abc[0], &height, sizeof(height));
memcpy(&abc[4], &age, sizeof(age));
and reverse
memcpy(&height, &abc[0], sizeof(height));
memcpy(&age, &abc[4], sizeof(age));

how should i do it in C#?

thx!
 
Back
Top