Expression.ConvertChecked Method (Expression, Type, MethodInfo)
Creates a UnaryExpression that represents a conversion operation that throws an exception if the target type is overflowed and for which the implementing method is specified.
Assemblies: System.Core (in System.Core.dll)
System.Linq.Expressions (in System.Linq.Expressions.dll)
'Declaration Public Shared Function ConvertChecked ( _ expression As Expression, _ type As Type, _ method As MethodInfo _ ) As UnaryExpression
- Type: System.Linq.Expressions.Expression
expression or type is Nothing.
method is not Nothing and the method it represents returns void, is not static (Shared in Visual Basic), or does not take exactly one argument.
No conversion operator is defined between expression.Type and type.
expression.Type is not assignable to the argument type of the method represented by method.
The return type of the method represented by method is not assignable to type.
expression.Type or type is a nullable value type and the corresponding non-nullable value type does not equal the argument type or the return type, respectively, of the method represented by method.
More than one method that matches the method description was found.
The following rules determine the implementing method for the operation:
If method is not Nothing, it is the implementing method. It must represent a non-void, static (Shared in Visual Basic) method that takes one argument.
Otherwise, 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 Nothing.
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 Nothing.
If the implementing method is not Nothing:
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 either or both of expression.Type or type are 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 Nothing:
If both expression.Type and type are non-nullable, the node is not lifted.
Otherwise the node is lifted.
.NET FrameworkSupported in: 4.6, 4.5, 4, 3.5
.NET Framework Client ProfileSupported in: 4, 3.5 SP1
Portable Class LibrarySupported in: Portable Class Library
.NET for Windows Store appsSupported in: Windows 8
Supported in: Windows Phone 8.1
Supported in: Windows Phone Silverlight 8.1
Supported in: Windows Phone Silverlight 8
Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.