共用方式為


Expression.MakeTry 方法

定義

建立 TryExpression,代表含指定之項目的 try 區塊。

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>

CatchBlock 的集合,代表要與 try 區塊產生關聯的 catch 陳述式。

傳回

建立的 TryExpression

適用於