Reputation: 148524
I'm a process of 64 bit, my int
size is 8 bytes.
I'm referencing a dll which is compiled to 32 bit.
This dll has a function which accepts an int
parameter.
What will happen?
I'm sending a 8 byte
to a 4 byte
"container" ?
Upvotes: 6
Views: 4326
Reputation: 14820
int
is always 32 bit (4 bytes) in C#, but not in some other languages like C++.
System.IntPtr
is 4 bytes on an x86 machine and 8 bytes on a 64 bit OS. Use this if you want OS dependend integer types.
Upvotes: 1
Reputation: 1076
In c# ints are the same size in 32bit and 64bit assemblies. int
or Int32
is always 32bit while long
or Int64
is always 64bit.
Upvotes: 4
Reputation: 1062770
No, in 64-bit / C#, an int
is still 4 bytes.
In C#, int
is always merely an alias to global::System.Int32
What will change is the reference size and pointer size, but that is all abstracted by the IL anyway - nothing needs to change. Note, though, that the CLI is only going to be 32 bit xor (nand?) 64 bit. You might need one of them to be "Any CPU".
Upvotes: 18