#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    2
    Rep Power
    0

    Bit positioning in C#


    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, *PDIVERT_TCPHDR;

    Please help me to convert this c++ struct to c# structure.
    It is very urgent. Please help me.
    Is bit manipulation possible in c#.net?.

    How can we set bit position in c# structure?
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,392
    Rep Power
    1871
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    2
    Rep Power
    0

    bit position in c# structure


    I think bit positions are not possible in c# structure. It is possible in c++. My question is how we can set bit position in c# structure.Is there any ways to do it in C#?
    For Example:
    typedef struct
    {
    UINT16 SrcPort:16;
    UINT16 DstPort:16;
    UINT32 SeqNum:32;
    UINT32 AckNum:16;
    UINT16 Reserved1:4;
    UINT16 HdrLength:4;
    }IP_HDR

IMN logo majestic logo threadwatch logo seochat tools logo