1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Does C# support bit fields (bit packing) in structure?

Discussion in 'C#' started by pbshines, Sep 20, 2013.

  1. pbshines

    pbshines New Member

    Joined:
    Sep 20, 2013
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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#?
     

Share This Page