2

I think bit fields are not possible in c# structure but it is possible 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 

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#?

2

1 Answer 1

3

No, C# does not offer any language features to define or access data storage smaller than 1 byte. You will have to mask and shift to isolate bit subranges within the data.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.