logo
  • 教程列表
  • SO官方文档
  • NullReferenceException
    • 空回归
    • 未初始化的变量
  1. StackOverflow 文档
  2. Visual Basic .NET Language 教程
  3. NullReferenceException
  4. 空回归

空回归

Created: November-22, 2018

Function TestFunction() As TestClass
    Return Nothing
End Function

坏代码

TestFunction().TestMethod()

好的代码

Dim x = TestFunction()
If x IsNot Nothing Then x.TestMethod()

Version = 14.0

空条件运算符

TestFunction()?.TestMethod()
  • 未初始化的变量
  • NullReferenceException

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 关于我们
  • 免责声明