473,320 Members | 2,048 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,320 software developers and data experts.

Declaring Data Buffer

I'm converting a project from C++ to C#. I need a structure with several
members that will be read from a file as a single block of data. But when I
try the following, I get an error for the data declaration that says "Array
size cannot be specified in variable declaration".

struct BLOCK_BUFF
{
UInt64 nextBlock;
UInt64 length;
byte data[500];
};

Why can't I declare a structure that looks like this, and how can I work
around this? Note that I want the data member memory to be continguous with
the rest of the structure so I can read it from the file at once.

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
May 15 '07 #1
1 2607
On Tue, 15 May 2007 12:14:34 -0600, "Jonathan Wood"
<jw***@softcircuits.comwrote:
>I'm converting a project from C++ to C#. I need a structure with several
members that will be read from a file as a single block of data. But when I
try the following, I get an error for the data declaration that says "Array
size cannot be specified in variable declaration".

struct BLOCK_BUFF
{
UInt64 nextBlock;
UInt64 length;
byte data[500];
};

Why can't I declare a structure that looks like this, and how can I work
around this? Note that I want the data member memory to be continguous with
the rest of the structure so I can read it from the file at once.

Thanks.
Maybe this:

struct BlockBuffer
{
UInt64 nextBlock;
UInt64 length;
[marshalAs(UnmanagedType.ByValArray, SizeConst=500)]
byte[] data;
};
--
Ludwig
http://www.coders-lab.be
May 15 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: | last post by:
Hi all, is there a better way to stream binary data stored in a table in sql 2005 to a browser in .net 2.0? Or is the code same as in .net 1.1? We noticed that in certain heavy load scenarios,...
9
by: Macca | last post by:
Hi, I have a synchronous socket server which my app uses to read data from clients. To test this I have a simulated client that sends 100 byte packets. I have set up the socket server so...
1
by: Spectre | last post by:
This is in a file called "UOEncryption.dll" Here is the info that the documentation gives: void Decompress(char *dest, const char *src, int *dest_size, int *src_size, HuffmanObj *obj) char...
10
by: athanasios.silis | last post by:
Hello everyone, i am attempting to make a structure #include "globalVars.h" struct myStruct{ int offset; unsigned char uChars; } saveVars, getVars;
1
by: Ilya N. Golubev | last post by:
There is already one function processing pointer values this way. And there may easily appear more, including wrappers for this function. For purposes of further discussion, consider simplified...
2
by: DBuss | last post by:
OK, I'm reading a multicast socket. It attaches fine, reads fine, all of that. The problem is that while some of the data I get is normal text (ASCII String), some of it is Binary Integer. ...
8
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using vs2005, .net 2, C# for Windows application. I use DllImport so I can call up a function written in C++ as unmanaged code and compiled as a dll us vs2005. My application is able to...
10
by: Markgoldin | last post by:
I am sending an XML data from not dontnet process to a .Net via socket listener. Here is a data sample: <VFPData> <serverdata> <coderun>updateFloor</coderun> <area>MD2</area>...
1
by: starter08 | last post by:
Hi, I have a C++ routine(client-side) which uploads an xml file to a web server by making a socket connection and sending all the post request through that socket. On the server side I have a cgi...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.