CKTIS / C#
System.Linq.Expressions.LambdaExpression: praktická reference
System.Linq.Expressions.LambdaExpression: praktická reference: LambdaExpression je negenerický základ stromu lambda s Body, Parameters a ReturnType.
Verze: .NET API; verified on .NET 10.0.14
Syntaxe
System.Linq.Expressions.LambdaExpression /* select a documented member or constructor */LambdaExpression je negenerický základ stromu lambda s Body, Parameters a ReturnType.
Použijte jej v reflexních nástrojích pro lambdy, jejichž typ delegáta je znám až za běhu.
Compile a dynamické volání ztrácejí část statické kontroly a při AOT nemusí být dostupné.
Počet a typy parametrů musí odpovídat typu delegáta, jinak sestavení lambdy vyvolá výjimku.
Úplný program skutečně používá System.Linq.Expressions.LambdaExpression; přesně očekávaný stdout je 1.
Příklady
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);
Výsledek
1
Úplný program skutečně používá `System.Linq.Expressions.LambdaExpression`; přesně očekávaný stdout je `1`.