Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent of unsigned long int in c#?

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?

like image 662
hiddenUser Avatar asked Mar 20 '23 17:03

hiddenUser


1 Answers

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.

like image 94
pid Avatar answered Apr 01 '23 20:04

pid