This documentation is archived and is not being maintained.

Expression.Constant Method (Object, Type)

Creates a ConstantExpression that has the Value and Type properties set to the specified values.

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

public static ConstantExpression Constant(
	Object value,
	Type type
)

Parameters

value
Type: System.Object

An Object to set the Value property equal to.

type
Type: System.Type

A Type to set the Type property equal to.

Return Value

Type: System.Linq.Expressions.ConstantExpression
A ConstantExpression that has the NodeType property equal to Constant and the Value and Type properties set to the specified values.

ExceptionCondition
ArgumentNullException

type is null.

ArgumentException

value is not null and type is not assignable from the dynamic type of value.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

.NET Framework

Supported in: 3.5
Show: