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;
Please help me to solve this issue? It is very urgent.
How can we set bit position in a C# Structure ?
VulpesPosted Sep 20, 2013, 6:52 AM
// make some changes
The output should be:
shine pbPosted Sep 20, 2013, 1:01 AM
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 positions?
Jignesh TrivediPosted Sep 19, 2013, 7:53 AM
hi,
your question is not too much clear.
you want to set array length from out side is it correct?
you may take help from contructor.
public struct myTest
{
public int[] b
// Constructor:
public myTest(int length)
{
b = new int[length];
}
}
hope this will help you.
Abhishek JainPosted Sep 19, 2013, 7:32 AM
I have referred it from here:
http://stackoverflow.com/questions/14464/bit-fields-in-c-sharp
Regards
AJ
Iftikar HussainPosted Sep 19, 2013, 7:31 AM
Not clear about your query. Can you explain bit more?
You can declare structure in C#. Please refer the below link
http://www.dotnetperls.com/struct
Regards,
Iftikar