What is intptr?

I did not understand what IntPtr is, can someone explain this? thanks

+7
source share
6 answers

This is a managed instance of void* .

You can use void* for use in managed code without having to use unsafe code in managed layers, such as C #.

+7
source

This is an integer, same as a pointer. 32 bits in 32-bit images, 64 in 64-bit images.

+8
source

This is a type of .NET platform that is used to represent a pointer or handle.

The IntPtr type is for integers whose size is platform dependent. That is, it is expected that an instance of this type will be 32-bit on 32-bit hardware and operating systems and 64-bit on 64-bit hardware and operating systems.

The IntPtr type can be used by languages ​​that support pointers, and as a common means of accessing data between languages ​​that run and do not support pointers.

IntPtr objects can also be used to store descriptors. For example, IntPtr instances are widely used in the System.IO.FileStream class to store files.

(from MSDSN )

+2
source

This is about c and C ++ - the intptr_t type, but the principle is the same. What is the uintptr_t data type

+1
source

Black box with a pointer. Sometimes you have languages ​​that do not support unsafe codes / pointers, and therefore you need to use IntPtr in the API.

I think its use has been reduced from .net 2, as many of its use cases are better suited for secure pens.

0
source

All Articles