jeudi 4 juin 2015

How to set a fixed buffer field element using reflection?

Here's a typical unsafe struct declaration that includes a fixed buffer field:

[StructLayout(LayoutKind.Explicit, Pack = 1)]
public unsafe struct MyStruct
{
    ...

    [FieldOffset(6)]
    public fixed ushort MyFixedBuffer[28];

    ...
}

How do I set an element of MyFixeBuffer using reflection?





Aucun commentaire:

Enregistrer un commentaire