Expression.Empty 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
创建具有 Void 类型的空表达式。
public:
static System::Linq::Expressions::DefaultExpression ^ Empty();
public static System.Linq.Expressions.DefaultExpression Empty();
static member Empty : unit -> System.Linq.Expressions.DefaultExpression
Public Shared Function Empty () As DefaultExpression
返回
DefaultExpression属性NodeType等于Default和Type属性设置为 Void.
示例
下面的代码示例演示如何创建空表达式并将其添加到块表达式。
// Add the following directive to your file:
// using System.Linq.Expressions;
// This statement creates an empty expression.
DefaultExpression emptyExpr = Expression.Empty();
// The empty expression can be used where an expression is expected, but no action is desired.
// For example, you can use the empty expression as the last expression in the block expression.
// In this case the block expression's return value is void.
var emptyBlock = Expression.Block(emptyExpr);
' Add the following directive to your file:
' Imports System.Linq.Expressions
' This statement creates an empty expression.
Dim emptyExpr As DefaultExpression = Expression.Empty()
' An empty expression can be used where an expression is expected but no action is desired.
' For example, you can use an empty expression as the last expression in a block expression.
' In this case, the block expression's return value is void.
Dim emptyBlock = Expression.Block(emptyExpr)
注解
空表达式可用于预期表达式,但不需要执行任何操作。 例如,可以将空表达式用作块表达式中的最后一个表达式。 在这种情况下,块表达式的返回值为 void。