IntPtr的VS UIntPtr

IntPtr的VS UIntPtr

问题描述:

这应该是简单的:我看到到处都是人用的IntPtr ,没有任何理由,我应该使用 UIntPtr 而不是?

This should be simple: I see everywhere people use IntPtr, is there any reason I should use UIntPtr instead?

似乎并不像会有一个很好的理由。从文档:

Doesn't seem like there would be a good reason to. From the docs:

备注

...

本的IntPtr类型符合CLS,   而UIntPtr类型不是。 只有   所述的IntPtr类型用于在公共   语言运行库。该UIntPtr类型   提供的大多维持   与IntPtr的建筑对称   类型。

The IntPtr type is CLS-compliant, while the UIntPtr type is not. Only the IntPtr type is used in the common language runtime. The UIntPtr type is provided mostly to maintain architectural symmetry with the IntPtr type.