struct inside struct

  • Thread starter =?iso-8859-1?Q?J=F3n_Sveinsson?=
  • Start date
?

=?iso-8859-1?Q?J=F3n_Sveinsson?=

Hello everone

I have code from c which I need to convert to c#, the c
code is following, as you can see there is a struct
inside struct

typedef struct
{
some variables....

typedef struct
{

some varibles...
}first;

}measure;

I have tried to convert this to to C# as following

public struct mesure
{
some variables...

public struct first
{
some varibles....
}
}

when I create instance of the struct I have just acces to
the varible which are inside the measure struct, I have
no Acces to the first struct,

if I try to take sizeof with the marshal as following it
just count the bytes for the variables for the measure
struct, not for the first struct;

How can this be managed

I have binary files which has been written by c
structered prgram, I need to read this file and get data
out of ot to write to database,

Regards

Jón Sveinsson
 
M

Mattias Sjögren

Jón,
I have tried to convert this to to C# as following

public struct mesure
{
some variables...

public struct first
{
some varibles....
}
}

You have to add an instance of the inner struct to the outer, that's
not done automatically

public struct mesure
{
some variables...

public first first;

public struct first
{
some varibles....
}
}



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top