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

  • Home
  • SEARCH
  • 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 6533195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:05:44+00:00 2026-05-25T10:05:44+00:00

Lets say In C++ I got code like this.. void * target uint32 *

  • 0

Lets say In C++ I got code like this..

void * target
uint32 * decPacket = (uint32 *)target;

So in C# it would be like..

byte[] target;
UInt32[] decPacket = (UInt32[])target;

Cannot convert type byte[] to uint[]

How do I convert this memory aligning thing C++ does to arrays to C#?

  • 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. Editorial Team
    Editorial Team
    2026-05-25T10:05:45+00:00Added an answer on May 25, 2026 at 10:05 am

    Well, something close would be to use Buffer.BlockCopy:

    uint[] decoded = new uint[target.Length / 4];
    Buffer.BlockCopy(target, 0, decoded, 0, target.Length);
    

    Note that the final argument to BlockCopy is always the number of bytes to copy, regardless of the types you’re copying.

    You can’t just treat a byte array as a uint array in C# (at least not in safe code; I don’t know about in unsafe code) – but Buffer.BlockCopy will splat the contents of the byte array into the uint array… leaving the results to be determined based on the endianness of the system. Personally I’m not a fan of this approach – it leaves the code rather prone to errors when you move to a system with a different memory layout. I prefer to be explicit in my protocol. Hopefully it’ll help you in this case though.

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

Sidebar

Related Questions

Lets say that I have got a vector like this. std::vector<a_complicated_whatever_identifier *> *something =
Lets say I've got two interchangeable pieces of code and I want to figure
Let's say I've got a trigger like this: CREATE TRIGGER trigger1 ON [dbo].[table1] AFTER
Let's say you've got a table like this: ID Cat1 Cat2 1 a red
Lets say I've got a table listing car brands or models: Cars : Id
in my Android app I've got two activities, lets say A and B. A
I got a default scoping like this which is dynamic: default_scope :conditions => [departure_date
Let's say you got a file containing texts (from 1 to N) separated by
Let's say I've got an object Customer with a couple properties ( ID ,
Let's say I've got a control and I want to prevent it from being

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.