System.Linq.Expressions.Error.ExpressionTypeDoesNotMatchLabel C# (CSharp) Méthode

ExpressionTypeDoesNotMatchLabel() static private méthode

ArgumentException with message like "Expression of type '{0}' cannot be used for label of type '{1}'"
static private ExpressionTypeDoesNotMatchLabel ( object p0, object p1 ) : Exception
p0 object
p1 object
Résultat System.Exception
        internal static Exception ExpressionTypeDoesNotMatchLabel(object p0, object p1)
        {
            return new ArgumentException(Strings.ExpressionTypeDoesNotMatchLabel(p0, p1));
        }
        /// <summary>

Usage Example

 // Standard argument validation, taken from ValidateArgumentTypes
 private static void ValidateGotoType(Type expectedType, ref Expression value, string paramName)
 {
     RequiresCanRead(value, paramName);
     if (!TypeUtils.AreReferenceAssignable(expectedType, value.Type))
     {
         // C# autoquotes return values, so we'll do that here
         if (TypeUtils.IsSameOrSubclass(typeof(Expression), expectedType) &&
             expectedType.IsAssignableFrom(value.GetType()))
         {
             value = Expression.Quote(value);
         }
         throw Error.ExpressionTypeDoesNotMatchLabel(value.Type, expectedType);
     }
 }
All Usage Examples Of System.Linq.Expressions.Error::ExpressionTypeDoesNotMatchLabel
Error