Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 158549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:42:04+00:00 2026-05-11T10:42:04+00:00

As you already may know,I’m migrating into C# and some things in C++ look

  • 0

As you already may know,I’m migrating into C# and some things in C++ look different.

C++ code

    BYTE packetBuffer[32] = {0};     *(LPWORD)(packetBuffer + 0) = 0xC;     *(LPWORD)(packetBuffer + 2) = 0x5000;     *(LPDWORD)(packetBuffer + 6) = dwArgs[13];     *(LPDWORD)(packetBuffer + 10) = *(keyArray2 + 0);     *(LPDWORD)(packetBuffer + 14) = *(keyArray2 + 1); 

Note dwArgs and keyArray2 are ‘array of DWORD’

This is how it’s placed

  1. packetbuffer[0] will be 0xC
  2. packetbuffer[1] will be 0x00
  3. packetbuffer[2] will be 0x50
  4. packetbuffer[3] will be 0x00

and so on

How to do that in C#?

I tried this,but it doesn’t work

packetBuffer[0] = 0xC; packetBuffer[2] = (byte)0x5000; //error packetBuffer[6] = (byte)dwArgs[13]; 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T10:42:04+00:00Added an answer on May 11, 2026 at 10:42 am

    You can use BitConverter to convert data to and from byte arrays. Unfortunately there’s no facility to copy into an existing array. My own EndianBitConverter in my MiscUtil library allows this if you need it, as well as allowing you to specify the endianness to use of course. (BitConverter is usually little endian in .NET – you can check it with the IsLittleEndian field.)

    For example:

    EndianBitConverter converter = EndianBitConverter.Little; converter.CopyBytes((short) 0xc, packetBuffer, 0); converter.CopyBytes((int) 0x5000, packetBuffer, 2); converter.CopyBytes(dwArgs[13], packetBuffer, 6); 

    etc. The cast to int in the second call to CopyBytes is redundant, but included for clarity (bearing in mind the previous line!).

    EDIT: Another alternative if you’d rather stick with the .NET standard libraries, you might want to use BinaryWriter with a MemoryStream.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As some of you may already know, there are some caching issues in Firefox/Chrome
As many of you may already know I have been having issues with another
those of you who read my previous questions may already know this: I'm currently
May be some body already used some open source component, writing on jquery. And
So as many of you may already know, CommonCrypto isn't included in the iPhone
May i know how do i loop so i can generate hash code for
I have a feeling I may already know the answer to this question, but
As everyone may already know, the simplest way to accept incoming TCP connections in
I think I may already know the answer to this, but here goes. I
I think I may know the answer to this question already, but I just

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.