struct inside struct

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jón Sveinsson

    #1

    struct inside struct

    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
  • Mattias Sjögren

    #2
    Re: struct inside struct

    Jón,
    [color=blue]
    >I have tried to convert this to to C# as following
    >
    >public struct mesure
    >{
    > some variables...
    >
    > public struct first
    > {
    > some varibles....
    > }
    >}[/color]

    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

    Please reply only to the newsgroup.

    Comment

    Working...