System.Linq.Expressions.Error.IncorrectTypeForTypeAs C# (CSharp) Method

IncorrectTypeForTypeAs() static private method

ArgumentException with message like "The type used in TypeAs Expression must be of reference or nullable type, {0} is neither"
static private IncorrectTypeForTypeAs ( object p0, string paramName ) : Exception
p0 object
paramName string
return System.Exception
        internal static Exception IncorrectTypeForTypeAs(object p0, string paramName)
        {
            return new ArgumentException(Strings.IncorrectTypeForTypeAs(p0), paramName);
        }
        /// <summary>

Usage Example

示例#1
0
 //CONFORMING
 public static UnaryExpression TypeAs(Expression expression, Type type)
 {
     RequiresCanRead(expression, "expression");
     ContractUtils.RequiresNotNull(type, "type");
     if (type.IsValueType && !TypeUtils.IsNullableType(type))
     {
         throw Error.IncorrectTypeForTypeAs(type);
     }
     return(new UnaryExpression(ExpressionType.TypeAs, expression, type, null));
 }
Error