到底什么是一个IntPtr是什么呢? [英] Just what is an IntPtr exactly?

查看:135
本文介绍了到底什么是一个IntPtr是什么呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过使用智能感知,看着别人的code,我也碰到过这种的IntPtr 输入;要使用的每一个它需要的时候我已经简单地把 IntPtr.Zero ,发现大多数功能工作。它究竟是什么,当/为什么使用它?

Through using IntelliSense and looking at other people's code, I have come across this IntPtr type; every time it has needed to be used I have simply put null or IntPtr.Zero and found most functions to work. What exactly is it and when/why is it used?

推荐答案

这是一个本机(特定于平台)大小的整数。它的内部重新psented为 $ P $无效* ,但公开为整数。每当你需要存储一个非托管指针,不想使用不安全 code您可以使用它。 IntPtr.Zero 是有效 NULL (一个空指针)。

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).

这篇关于到底什么是一个IntPtr是什么呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆