By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,742 Members | 1,227 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,742 IT Pros & Developers. It's quick & easy.

struct inside struct

P: n/a
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
Nov 15 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.