C# Long to C++ Long
-
What do I use to represent a C++ Long in C#? I know DWORD is int, and C# Long is not the same as C++ LONG. C# uses 8 bytes, C++ uses 4. So what do I do to wrap one to the other? Thanks Cata
-
What do I use to represent a C++ Long in C#? I know DWORD is int, and C# Long is not the same as C++ LONG. C# uses 8 bytes, C++ uses 4. So what do I do to wrap one to the other? Thanks Cata
In Visual Basic 6,
Integer
equals C#'sshort
, so I think that this may be the case with C++ too (I don't know C++, you see). Thus,int
should do the trick. - Daniël Pelsmaeker"To survive it is often necessary to fight, and to fight you have to dirty yourself." - George Orwell
-
What do I use to represent a C++ Long in C#? I know DWORD is int, and C# Long is not the same as C++ LONG. C# uses 8 bytes, C++ uses 4. So what do I do to wrap one to the other? Thanks Cata
C++ - C# (Win32) ---------------- int = int long = int __int64 = long DWORD = uint Regards, Alvaro
He who laughs last, thinks slowest.
-
C++ - C# (Win32) ---------------- int = int long = int __int64 = long DWORD = uint Regards, Alvaro
He who laughs last, thinks slowest.
Actually, be careful with
uint
. It's not CLS-compliant and you should try to avoid those. I have almost always usedint
forDWORD
with absolutely no problems. Microsoft does the same throughout the BCL, too. WhileDWORD
's can't be negative, the bit representation is still the same so even passing a negativeint
to aDWORD
in some native function works.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
Actually, be careful with
uint
. It's not CLS-compliant and you should try to avoid those. I have almost always usedint
forDWORD
with absolutely no problems. Microsoft does the same throughout the BCL, too. WhileDWORD
's can't be negative, the bit representation is still the same so even passing a negativeint
to aDWORD
in some native function works.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
Heath Stewart wrote: It's not CLS-compliant and you should try to avoid those. as long as it is not publicly accessable, iow locals, private fields. one should always use the correct type though, although int will probably work 31/32 times :) leppie::AllocCPArticle("Zee blog");
Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it. -
Heath Stewart wrote: It's not CLS-compliant and you should try to avoid those. as long as it is not publicly accessable, iow locals, private fields. one should always use the correct type though, although int will probably work 31/32 times :) leppie::AllocCPArticle("Zee blog");
Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.leppie wrote: although int will probably work 31/32 times Exactly! :) As I was saying, though, this usually isn't a problem. The biggest reason I typically use
int
is because Microsoft does in their BCL. Since they wrote the .NET Framework, seems reasonable to me. Of course, I guess worrying about CLS-compliancy is pretty moot if you're using auint
to P/Invoke a native call, huh? ;P-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----