tags:

views:

232

answers:

2
+1  Q: 

IntPtr vs UIntPtr

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

+3  A: 

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

Remarks

...

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.

womp
+1  A: 

Well according to Microsoft UIntPtr is provided mostly for architectural symmetry. Another interesting point is that UIntPtr is not CLS compliant.

On the surface it would seem that IntPtr is the preferred option. However, if you know you will be doing pointer arithmetic then UIntPtr may be a better choice since in the off chance there were some obscure problem dealing with negative values.

Brian Gideon