please help me, i have this code in c#, i need copy array of bytes to array of structures in the fastest way.
I have this structure:
[StructLayout(LayoutKind.Sequential, Pack = 1)]
unsafe public struct TsVarGroup
{
public uint Addr;
public ushort Count;
public short CAddr;
public ushort CSW;
public fixed byte NamePrefix[9];
public string GetNamePrefix()
{
fixed (byte* ptr = NamePrefix)
{
return new string((sbyte*)ptr, 0, 8, Encoding.ASCII);
}
}
asVarGroups = new TsVarGroup[sVarTable.Count];
byte[] dataVarGroups = Connection.GETMEM("R", (sVarTable.Addr - ADDRESS_OFFSET), asVarGroups.Length * TS_VARGROUP_SIZE);
Is there any easy way how to copy aray of bytes “dataVarGroups” to array of structures asVarGroups??
Thank you very much
I tried this: Buffer.BlockCopy(dataVarGroups, 0, asVarGroups, 0, dataVarGroups.Length); but it is only for primitives elemtens.
New contributor
jirikk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.