Expression.Empty Metod

Definition

Skapar ett tomt uttryck som har Void typen .

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

Returer

En DefaultExpression som har NodeType egenskapen lika med Default och egenskapen inställd på TypeVoid.

Exempel

I följande kodexempel visas hur du skapar ett tomt uttryck och lägger till det i ett blockuttryck.

// 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)

Kommentarer

Ett tomt uttryck kan användas där ett uttryck förväntas men ingen åtgärd önskas. Du kan till exempel använda ett tomt uttryck som det sista uttrycket i ett blockuttryck. I det här fallet är blockuttryckets returvärde ogiltigt.

Gäller för