ParameterExpression param = Expression.Parameter(typeof(int), "x"); UnaryExpression negExpr = Expression.Negate(param);
ParameterExpression param = Expression.Parameter(typeof(object), "obj"); UnaryExpression castExpr = Expression.Convert(param, typeof(string));In this example, we create a parameter expression with the type of object and the name "obj". We then create a UnaryExpression with the Convert operator and pass in the parameter expression and the type we want to convert to (in this case, string). The System.Linq.Expressions namespace is part of the .NET Framework class library.