什么是NullReferenceException

试图访问或取消引用空对象引用时引发的异常。

继承链

Object
Exception
SystemException
NullReferenceException

说明

尝试访问值为空的类型上的成员时,将引发NullReferenceException异常。NullReferenceException异常通常反映开发人员错误,可能引发的情况如下:
  1. 忘记了实例化引用类型
  2. 在初始化数组之前,忘记了维度。
  3. 从方法获取null返回值,然后对返回的类型调用方法。
  4. 因此,永远不会计算 null 的测试。
  5. NullReferenceException 异常。
  6. NullReferenceException 异常。

NullReferenceExceptioncallvirtcpblkcpobjinitblkldelem.<type>ldelemaldfldldfldaldind.<type>ldlenstelem.<type>stfldstind.<type>throwunbox

HRESULT

NullReferenceException 使用值为0x80004003 的 HRESULT COR_E_NULLREFERENCE。

 

相关文章:

  • 2021-08-03
  • 2021-04-09
  • 2021-04-11
  • 2021-07-05
  • 2021-04-11
  • 2021-06-25
  • 2022-02-20
  • 2021-06-19
猜你喜欢
  • 2022-01-10
  • 2021-08-31
  • 2022-02-04
相关资源
相似解决方案