fixed arrays

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • leibnizster

    #1

    fixed arrays

    Hello



    I have a c++ unmanaged struct that has as one of its components an
    array of constant length. To transform it in managed array I have to
    use something like:

    public struct blabla
    {
    ....
    fixed public char fixedArray[10];
    ....
    }

    when I use the struct, it is clear that fixedArray is of type char*.
    The question is if i can use somehow fixedArray as an array, without
    the pointer logic.

    Thanks

  • Mattias Sjögren

    #2
    Re: fixed arrays

    [color=blue]
    >The question is if i can use somehow fixedArray as an array, without
    >the pointer logic.[/color]

    No you can't, it's not a real array. But perhaps you can change your
    struct to

    public struct blabla
    {
    ....
    [MarshalAs(Unman agedType.ByValA rray, SizeConst=10)]
    public char[] fixedArray;
    ....
    }


    Mattias

    --
    Mattias Sjögren [C# MVP] mattias @ mvps.org
    http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
    Please reply only to the newsgroup.

    Comment

    Working...