473,387 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to declare a byte buffer in unmanaged c# structure?

Expand|Select|Wrap|Line Numbers
  1. typedef struct 
  2. {
  3.     UINT32 header;
  4.     UINT8 data[];
  5. } DATA_HDR
How can I convert this structure to c# structure?
When I used fixed byte[] in c#, it will increase the size of the structure.

Expand|Select|Wrap|Line Numbers
  1.   [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi,Pack=1)]
  2.         unsafe public struct DATAPACKET
  3.         {
  4.             public UInt32 header;
  5.             public unsafe fixed byte data[217];
  6.         }
How can I declare a buffer in c# structure without specify the size?.

Please help me
Sep 23 '13 #1
0 1091

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Zulik | last post by:
Hello, I might have a bad day today but I have a byte buffer holding binary numbers. Now, I want to convert this to byte buffer with hex numbers. Is there any elegant way of doing that? Some...
4
by: the openBack | last post by:
I'm having a problem that I don't quite understand. I'm using someone else's class: using HANDLE = System.IntPtr; namespace Win32 { // other stuff here public struct SHFILEINFO {
2
by: andy.dreistadt | last post by:
Hi all, I came across another problem that is probably pretty easy but, again, due to my rusty-ness with C, I'm a little stumped. I have a struct that looks like this: /* Instrument Data...
0
by: Jack | last post by:
I am trying to develop a simple telnet client in MS.NET I have a small wrapper around the System.Net.Sockets.Socket class which takes care of sending and receiving data and handing it off to a...
3
by: zhphust | last post by:
I want to convert a object of a managed class to a unmanaged structure that has the same member with that managed class. Can anybody tell me how i can do it? Thanks in advance. -- zhphust...
8
by: John Dann | last post by:
Trying to declare a structure that will contain a couple of fixed-size arrays. I'm trying eg: Structure IndexRecord Dim testarray(16) as Byte etc End Structure But vb.net is refusing to let...
0
by: suneelp | last post by:
Hi! I am keep getting following error. "Type 'myclass+myRecord' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed.". it works fine, If I convert...
3
by: bill | last post by:
All, I have the following: ...... unsafe public struct Example { public double we;
16
by: pkoniusz | last post by:
Hello everybody, Been just thinking how actually one could convert the following unmanaged code to the managed C++: struct JustAnExample { char value1; int value2; // etc ....
0
by: shofu_au | last post by:
Hi Group, I am trying without much luck to pack messages into a byte buffer using get and set accessors. I have attached a simplified example of what I am trying to do using byte variables....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.