Expression.Convert Method (Expression, Type)
Creates a UnaryExpression that represents a conversion operation.
Assembly: System.Core (in System.Core.dll)
- Type: System.Linq.Expressions.Expression
The following rules determine the implementing method for the operation :
If either expression.Type or type is a user-defined type that defines an implicit or explicit conversion operator, the MethodInfo that represents that operator is the implementing method.
If both expression.Type and type represent numeric or Boolean types, or nullable or non-nullable enumeration types, the implementing method is null.
If either expression.Type or type is a reference type and an explicit boxing, unboxing, or reference conversion exists from expression.Type to type, the implementing method is null.
Lifted versus Non-Lifted
If the implementing method is not null:
If expression.Type is assignable to the argument type of the implementing method and the return type of the implementing method is assignable to type, the node is not lifted.
If one or both of expression.Type or type is a nullable value type and the corresponding non-nullable value types are equal to the argument type and the return type of the implementing method respectively, the node is lifted.
If the implementing method is null:
If both expression.Type and type are non-nullable, the node is not lifted.
Otherwise the node is lifted.
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.