|
Il presente articolo è stato tradotto automaticamente. Passare il puntatore sulle frasi nell'articolo per visualizzare il testo originale. Ulteriori informazioni.
|
Traduzione
Originale
|
Metodo Expression.Call (Expression, MethodInfo, Expression, Expression)
.NET Framework 4.5
Spazio dei nomi: System.Linq.Expressions
Assembly: System.Core (in System.Core.dll)
public static MethodCallExpression Call( Expression instance, MethodInfo method, Expression arg0, Expression arg1 )
Parametri
- instance
- Tipo: System.Linq.Expressions.Expression
Expression specifica che l'istanza per una chiamata dell'istanza. (null della sessione per (condiviso in Visual Basic) un metodo statico).
- method
- Tipo: System.Reflection.MethodInfo
MethodInfo che rappresenta il metodo di destinazione.
- arg0
- Tipo: System.Linq.Expressions.Expression
Expression che rappresenta il primo argomento.
- arg1
- Tipo: System.Linq.Expressions.Expression
Expression che rappresenta il secondo argomento.
Valore restituito
Tipo: System.Linq.Expressions.MethodCallExpression// Add the following directive to your file: // using System.Linq.Expressions; public class SampleClass { public int AddIntegers(int arg1, int arg2) { return arg1 + arg2; } } static public void TestCall() { // This expression represents a call to an instance method that has two arguments. // The first argument is an expression that creates a new object of the specified type. Expression callExpr = Expression.Call( Expression.New(typeof(SampleClass)), typeof(SampleClass).GetMethod("AddIntegers", new Type[] { typeof(int), typeof(int) }), Expression.Constant(1), Expression.Constant(2) ); // Print out the expression. Console.WriteLine(callExpr.ToString()); // The following statement first creates an expression tree, // then compiles it, and then executes it. Console.WriteLine(Expression.Lambda<Func<int>>(callExpr).Compile()()); // This code example produces the following output: // // new SampleClass().AddIntegers(1, 2) // 3 }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (ruoli di base del server non supportati), Windows Server 2008 R2 (ruoli di base del server supportati con SP1 o versione successiva, Itanium non supportato)
.NET Framework non supporta tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.