Callum Rogers Callum Rogers - 5 months ago 31
C# Question

Just what is an IntPtr exactly?

Through using IntelliSense and looking at other people's code, I have come across this

type; every time it has needed to be used I have simply put
and found most functions to work. What exactly is it and when/why is it used?


It's a "native (platform-specific) size integer." It's internally represented as void* but exposed as an integer. You can use it whenever you need to store an unmanaged pointer and don't want to use unsafe code. IntPtr.Zero is effectively NULL (a null pointer).