为size_t的.NET相当于 [英] .NET equivalent of size_t
问题描述
我有一块.NET code,我想移植到64位。在codeS基本上是一组的P / Invoke的调用其他的C DLL。其中一个在C DLL中的函数具有参数为size_t。我应该在P用什么数据类型/调用签名,以便编组工作正常。我想用的IntPtr或UIntPtr,但有人说,他们是在.NET中的指针等同的事情,不应该使用它。有谁知道什么是正确的类型,这是?
I have a piece of .NET code which I want to port to 64-bit. The codes basically is a set of P/Invoke calls to some other C dll. One of the functions in the C dll has a parameter 'size_t'. What datatype should I use in my P/Invoke signature so that the marshalling works fine. I was thinking of using a IntPtr or a UIntPtr but some say that they are a pointer equivalent thing in .NET and shouldnt be using it. Does anyone know what the correct type for this is?
推荐答案
UIntPtr将工作(IntPtr的可能会工作过,但为size_t是无符号的,所以UIntPtr是一个更好的配合)
UIntPtr will work (IntPtr would probably work too, but size_t is unsigned, so UIntPtr is a better fit)
JaredPar写在他的博客东西(和<一href="http://blogs.msdn.com/jaredpar/archive/2006/04/13/follow-up-pinvoke-with-32-and-64-bit.aspx">follow-up)关于这一点。
JaredPar has written something on his blog (and a follow-up) about this.
这篇关于为size_t的.NET相当于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!