Expression.MakeTry 方法

定义

创建一个表示具有指定元素的 try 块的 TryExpression

public:
 static System::Linq::Expressions::TryExpression ^ MakeTry(Type ^ type, System::Linq::Expressions::Expression ^ body, System::Linq::Expressions::Expression ^ finally, System::Linq::Expressions::Expression ^ fault, System::Collections::Generic::IEnumerable<System::Linq::Expressions::CatchBlock ^> ^ handlers);
public static System.Linq.Expressions.TryExpression MakeTry (Type type, System.Linq.Expressions.Expression body, System.Linq.Expressions.Expression finally, System.Linq.Expressions.Expression fault, System.Collections.Generic.IEnumerable<System.Linq.Expressions.CatchBlock> handlers);
public static System.Linq.Expressions.TryExpression MakeTry (Type? type, System.Linq.Expressions.Expression body, System.Linq.Expressions.Expression? finally, System.Linq.Expressions.Expression? fault, System.Collections.Generic.IEnumerable<System.Linq.Expressions.CatchBlock>? handlers);
static member MakeTry : Type * System.Linq.Expressions.Expression * System.Linq.Expressions.Expression * System.Linq.Expressions.Expression * seq<System.Linq.Expressions.CatchBlock> -> System.Linq.Expressions.TryExpression
Public Shared Function MakeTry (type As Type, body As Expression, finally As Expression, fault As Expression, handlers As IEnumerable(Of CatchBlock)) As TryExpression

参数

type
Type

try 表达式的结果类型。 如果为 null,则正文和所有处理程序必须具有相同的类型。

body
Expression

try 块的主体。

finally
Expression

finally 块的主体。 如果 try 块不具有关联的 finally 块,则传递 null。

fault
Expression

fault 块的主体。 如果 try 块不具有关联的 fault 块,则传递 null。

handlers
IEnumerable<CatchBlock>

表示要与 try 块关联的 catch 语句的 CatchBlock 的集合。

返回

创建的 TryExpression

适用于