CKTIS / C#
System.Linq.Expressions.LambdaExpression: riferimento pratico
System.Linq.Expressions.LambdaExpression: riferimento pratico: LambdaExpression è la base non generica di un albero lambda con Body, Parameters e ReturnType.
Versione: .NET API; verified on .NET 10.0.14
Sintassi
System.Linq.Expressions.LambdaExpression /* select a documented member or constructor */LambdaExpression è la base non generica di un albero lambda con Body, Parameters e ReturnType.
Usala in strumenti riflessivi che gestiscono lambda il cui tipo delegate è noto solo a runtime.
Compile e invocazione dinamica perdono parte del controllo statico e possono non essere disponibili con AOT.
Numero e tipi dei parametri devono corrispondere al delegate o la costruzione della lambda genera eccezione.
Il programma completo usa realmente System.Linq.Expressions.LambdaExpression; lo stdout esatto atteso è 1.
Esempi
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;
LambdaExpression expression = (Expression<Func<int, int>>)(value => value * 2);
Console.WriteLine(expression.Parameters.Count);
Risultato
1
Il programma completo usa realmente `System.Linq.Expressions.LambdaExpression`; lo stdout esatto atteso è `1`.