Struct with fixed-length array member - is it possible?
- From: "Rafal Gwizdala" <gwrafal@xxxxxxxxxxxxxx>
- Date: Mon, 18 Apr 2005 23:51:35 +0200
Hello,
Can you provide some hints on how would you solve a problem like this? I'm
out of ideas...
Here's the problem: Let's imagine a C structure containing a fixed-size
array
struct XYZ
{
int V1;
int V2;
double V3[50];
};
This structure, when allocated, occupies a contiguous block of memory (408
bytes in my compiler).
Now I would like to have the same structure in C#, such that it would have
THE SAME MEMORY LAYOUT as the C structure. The memory size does not need to
be identical as in C, but the structure should occupy a single memory block
and all data, including the array, should be placed in this block.
There is no possibility in C# to declare a fixed-size array and to 'embed'
it completely in a struct. When I make a declaration like this:
public struct XYZ
{
int V1;
int V2;
double[] V3;
}
the V3 member is a reference to array object, not the array itself.
Can you think of any way to get the C/C++ layout?
Best Regards,
Rafal Gwizdala
.
- Follow-Ups:
- Re: Struct with fixed-length array member - is it possible?
- From: Daniel O'Connell [C# MVP]
- Re: Struct with fixed-length array member - is it possible?
- Prev by Date: Re: How to get a keypress event in an console application
- Next by Date: Array of value-types
- Previous by thread: Monitor Exchange 2K queues
- Next by thread: Re: Struct with fixed-length array member - is it possible?
- Index(es):
Relevant Pages
|