Empty Method
TOC
Collapse the table of content
Expand the table of content

Expression.Empty Method

Creates an empty expression that has Void type.

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

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.

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.

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



.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2016 Microsoft