shine pb

shine pb

  • 2.1k
  • 40
  • 12.9k

Does C# support struct bit definitions?

Sep 19 2013 7:19 AM
Does C# support struct bit definitions?. 
For example is there a way to declare a structure like this in c#.net?

typedef struct

{

    UINT16 SrcPort;

    UINT16 DstPort;

    UINT32 SeqNum;

    UINT32 AckNum;

    UINT16 Reserved1:4;

    UINT16 HdrLength:4;

    UINT16 Fin:1;

    UINT16 Syn:1;

    UINT16 Rst:1;

    UINT16 Psh:1;

    UINT16 Ack:1;

    UINT16 Urg:1;

    UINT16 Reserved2:2;

    UINT16 Window;

    UINT16 Checksum;

    UINT16 UrgPtr;

} DIVERT_TCPHDR

Please help me to solve this issue? It is very urgent.

How can we set bit position in a C# Structure ?

Answers (5)