Information.IsNothing(Object) 方法

定義

回傳 Boolean 一個值,表示某表達式是否未被指派物件。

public:
 static bool IsNothing(System::Object ^ Expression);
public static bool IsNothing(object Expression);
static member IsNothing : obj -> bool
Public Function IsNothing (Expression As Object) As Boolean

參數

Expression
Object

必須的。 Object 表達式。

傳回

回傳 Boolean 一個值,表示某表達式是否未被指派物件。

範例

以下範例使用該 IsNothing 函式來判斷物件變數是否與任何物件實例相關聯。

Dim testVar As Object
' No instance has been assigned to variable testVar yet.
Dim testCheck As Boolean
' The following call returns True.
testCheck = IsNothing(testVar)
' Assign a string instance to variable testVar.
testVar = "ABCDEF"
' The following call returns False.
testCheck = IsNothing(testVar)
' Disassociate variable testVar from any instance.
testVar = Nothing
' The following call returns True.
testCheck = IsNothing(testVar)

備註

IsNothing 若表達式代表一個目前沒有物件指派的物件變數,則回傳 True ;否則,則回傳 False

IsNothing 旨在處理參考型別。 值類型無法保留 「無」 的值,若你指派 Nothing 該值,該值會回復預設值。 如果你在 中 Expression提供一個值型態, IsNothing 總是返回 False

適用於

另請參閱