Information.IsNothing(Object) 方法

定义

返回一个 Boolean 值,该值指示表达式是否没有为其分配对象。

public:
 static bool IsNothing(System::Object ^ Expression);
public static bool IsNothing(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 值,并且还原为默认值。 如果提供值类型 ExpressionIsNothing 则始终返回 False

适用于

另请参阅