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)

注解

IsNothingTrue如果表达式表示当前没有分配给它的对象变量,则False返回 ;否则返回 。

IsNothing 适用于引用类型。 值类型不能保留 Nothing 值,如果分配给 Nothing 该值,则还原到其默认值。 如果在 中 Expression提供值类型, IsNothing 则始终返回 False

适用于

另请参阅