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

Ask A Question

Stats

  • Questions 124k
  • Answers 124k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer EDIT: Okay, I've now tracked it down a lot further… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer The '|' is the bitwise OR operator. It basically combines… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer Start the project with Ctrl+F5 instead of just F5. The… May 12, 2026 at 1:18 am

Related Questions

As you already may know,I'm migrating into C# and some things in C++ look
I continue with a MVC Web App, and now I'm between the concepts of
As you probably already know, you may have multiple classes on elements separated by
I have been utilizing Scott Gu's tutorials on LINQ to SQL to try to
I am trying to formulate a selector to select a set of visible elements.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.