Expression.MakeMemberAccess(Expression, MemberInfo) 方法

定義

建立代表存取欄位或屬性的 MemberExpressionCreates a MemberExpression that represents accessing either a field or a property.

public:
 static System::Linq::Expressions::MemberExpression ^ MakeMemberAccess(System::Linq::Expressions::Expression ^ expression, System::Reflection::MemberInfo ^ member);
public static System.Linq.Expressions.MemberExpression MakeMemberAccess (System.Linq.Expressions.Expression expression, System.Reflection.MemberInfo member);
public static System.Linq.Expressions.MemberExpression MakeMemberAccess (System.Linq.Expressions.Expression? expression, System.Reflection.MemberInfo member);
static member MakeMemberAccess : System.Linq.Expressions.Expression * System.Reflection.MemberInfo -> System.Linq.Expressions.MemberExpression
Public Shared Function MakeMemberAccess (expression As Expression, member As MemberInfo) As MemberExpression

參數

expression
Expression

Expression,代表成員所屬的物件。An Expression that represents the object that the member belongs to. 如果是靜態成員,可以是 Null。This can be null for static members.

member
MemberInfo

MemberInfo,說明要存取的欄位或屬性。The MemberInfo that describes the field or property to be accessed.

傳回

MemberExpression

MemberExpression,由呼叫適當的 Factory 方法所產生。The MemberExpression that results from calling the appropriate factory method.

例外狀況

membernullmember is null.

member 不代表欄位或屬性。member does not represent a field or property.

備註

您可以使用這個方法來建立 MemberExpression ,其代表存取欄位或屬性(視的型別而定) memberThis method can be used to create a MemberExpression that represents accessing either a field or a property, depending on the type of member. 如果 member 的型別為 FieldInfo ,這個方法會呼叫 Field 以建立 MemberExpressionIf member is of type FieldInfo, this method calls Field to create the MemberExpression. 如果 member 的型別為 PropertyInfo ,這個方法會呼叫 Property 以建立 MemberExpressionIf member is of type PropertyInfo, this method calls Property to create the MemberExpression.

適用於