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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top