UnaryExpression Class
Represents an expression that has a unary operator.
Assembly: System.Core (in System.Core.dll)
The following table summarizes the factory methods that can be used to create a UnaryExpression that has a specific node type.
Factory Method | |
|---|---|
In addition, the MakeUnary methods can also be used to create a UnaryExpression. These factory methods can be used to create a UnaryExpression of any node type that represents a unary operation. The parameter of these methods that is of type NodeType specifies the desired node type.
The following example creates a UnaryExpression object that represents the reference conversion of a non-nullable integer expression to the nullable integer type.
' Create a UnaryExpression that represents a reference ' conversion of an Integer to an Integer? (a nullable Integer). Dim typeAsExpression As System.Linq.Expressions.UnaryExpression = _ System.Linq.Expressions.Expression.TypeAs( _ System.Linq.Expressions.Expression.Constant(34, Type.GetType("System.Int32")), _ Type.GetType("System.Nullable`1[System.Int32]")) Console.WriteLine(typeAsExpression.ToString()) ' This code produces the following output: ' ' (34 As Nullable`1)
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.