Expression.Empty Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Creates an empty expression that has Void type.

Namespace:  System.Linq.Expressions
Assembly:  System.Core (in System.Core.dll)

Syntax

'Declaration
Public Shared Function Empty As DefaultExpression
public static DefaultExpression Empty()

Return Value

Type: System.Linq.Expressions.DefaultExpression
A DefaultExpression that has the NodeType property equal to Default and the Type property set to Void.

Remarks

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.

Examples

The following code example shows how to create an empty expression and add it to a block expression.

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

Version Information

Silverlight

Supported in: 5, 4

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.