Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   Does C# support bit fields (bit packing) in structure? (http://www.go4expert.com/forums/c-sharp-support-bit-fields-bit-packing-t29819/)

pbshines 20Sep2013 11:20

Does C# support bit fields (bit packing) in structure?
 
I think bit fields are not possible in c# structure. It is possible in c++.
Code:

typedef struct
{
    UINT16 SrcPort:16;
    UINT16 DstPort:16;
    UINT32 SeqNum:32;
    UINT32 AckNum:16;
    UINT16 Reserved1:4;
    UINT16 HdrLength:4;
}IP_HDR

How can we create a structure like this in c# with bit fields?

My question is how we can set bit fields in C# structure.Is there any ways to do it in C#?


All times are GMT +5.5. The time now is 05:15.