Apparently it's important to use Int32 instead of int when messing around with the DLLImport stuff?

In C #, when you fiddled with this DLLImport / (unmanaged?) Code, I read somewhere that it is important to use the exact type Int32 instead of int. It's true? And can someone think about why this is important for this?

+2


a source to share


2 answers


I think it is more likely that you read about using IntPtr

instead int

. As others have said, int

and are Int32

equivalent.



In fact, no problem exchange int

and IntPtr

a 32-bit system, since they are the same size (4 bytes). The problem arises when on a 64 bit system - if you use int

instead IntPtr

, it is now the wrong size (4 bytes instead of 8 bytes) and may cause errors.

+6


a source


I don't believe this is true. int

is an alias for Int32

. They mean the same thing and will be compiled for the same IL.



A list of aliases can be found here .

+1


a source







All Articles