gordon

gordon

  • NA
  • 36
  • 0

Structures and fixed length arrays

Oct 26 2007 11:05 AM

I'm trying to create a structure with a fixed length char array in it see below. The field length needs to be fixed because when the structure is full it's converted to a byte array and sent to another process by an IP packet. The process on the other end need to know the length of each field so it can be decoded properly. If anyone can help or has a better idea I would appreciate the help.

Thanks in advance

 

[StructLayout(LayoutKind.Sequential, Pack=1)]

public struct rec

{

   public ushort MsgId;         // Message Id

   public double TOD;         // Time of Day

   public ushort Day;            // Day of year

   public char[] sitename;

...

...

}

   


Answers (3)