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

  • 關於本站
  • 免責聲明