Question

I have a C struct that is defined as follows:

typedef struct {

    unsigned long int a;

} TEST;

I want to create a C# equivalent of this struct?

Any help? What is confusing me is that "unsigned long int" is at least 32-bit, what does that mean, it's either 32-bit, 64-bit or 16-bit, right?

Was it helpful?

Solution

You want an uint or ulong depending on what an int or long was on your native C platform:

  • C# uint is 32 bits
  • C# ulong is 64 bits

The at least and platform dependency is a necessary concern in C because it is actually translated into machine code and C was developed for many architectures with varying word sizes. C# on the contrary is defined against a virtual machine (exactly like Java or Javascript) and thus can abstract the hardware's word size in favor of one defined by the language's standard VM (the CLR in C#). Differences between the VM and harware word size are taken care of by the VM and hidden to the hosted code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top