From: Ben Voigt [C++ MVP] on
> This works (thanks) but can you freely mix managed and unmanaged types. If
> "T" is a "long" for instance, it's 64 bits managed and 32 bits unmanaged
> (on a 32 bit system in the latter case). So what are the rules for mixing
> them

No it isn't. In C++ and C++/CLI, long is 32 bits. long long is 64 bits.

In C#, long is 64 bits.

There is no System.Long.

"long" (and related keywords) are *language-dependent* aliases for the
System.[U]Int(16|32|64) types.

> like this (or rather, what does "T" mean in the case of
> "ICollection<long>" for instance). Note that even for types that are the
> same ("int" for

System.Collections.Generic.ICollection<System.Int32> of course

> instance, at least on a 32-bit platform), can you freely mix the managed
> and unmanaged version (isn't it like mixing apples and oranges, even they
> map to the same thing).

Yes. native int and System.Int32 are considered the SAME type in C++/CLI.
There's not a mapping from one to the other, they are BOTH managed and
native. This duality is unique to the built-in types, there is no way to
make a user-defined value type that works the same way.