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 648057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:47:27+00:00 2026-05-13T21:47:27+00:00

Struct { byte F1[2] SHORT F2 byte F3[512] } BPD CBD { SHORT CLENGTH

  • 0
Struct {
 byte F1[2]
 SHORT F2
 byte F3[512]
} BPD


CBD
{
 SHORT CLENGTH
 byte DATA[]
}

Above are 2 c++ structure. Here SHORT is of 2 byte signed.
What would be the best way to convert it into C#?

(Note that in 2nd struture length of DATA is uundefined.)

I have seen following two links.

Fixed length strings or structures in C#

and

Reading a C/C++ data structure in C# from a byte array

After reading data into structure i need to covert the short variable to big endian. (reversing bytes).

  • 1 1 Answer
  • 3 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-13T21:47:27+00:00Added an answer on May 13, 2026 at 9:47 pm

    Solved myself.

    Structures are good but if you are not going to modify any data classes are better to use.
    I have create classes in c# for c++ structure and for big to little endian conversion i have create 3 library functions and it works for me.

    Thnaks everybody for the valuable input.

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

Sidebar

Related Questions

What would be the best way to fill a C# struct from a byte[]
I have such a C++ structure: typedef struct _FILE_OP_BLOCK { unsigned short fid; //
I have a byte stream I need parsed into a struct, and I also
struct TimerEvent { event Event; timeval TimeOut; static void HandleTimer(int Fd, short Event, void
typedef struct { nat id; char *data; } element_struct; typedef element_struct * element; void
In Java, a byte or short is stored in the JVM's 'natural' word length,
I would like to do the following: [StructLayout(LayoutKind.Sequential, Pack = 1)] public struct SomeStruct
struct elem { int i; char k; }; elem user; // compile error! struct
I have the following struct in C++: #define MAXCHARS 15 typedef struct { char
Say I have a struct s with an int pointer member variable i. I

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.