Expression.MakeMemberAccess(Expression, MemberInfo) Method

Definition

Creates 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);
static member MakeMemberAccess : System.Linq.Expressions.Expression * System.Reflection.MemberInfo -> System.Linq.Expressions.MemberExpression

Parameters

expression
Expression

An Expression that represents the object that the member belongs to. This can be null for static members.

member
MemberInfo

The MemberInfo that describes the field or property to be accessed.

Returns

The MemberExpression that results from calling the appropriate factory method.

Exceptions

member is null.

member does not represent a field or property.

Remarks

This method can be used to create a MemberExpression that represents accessing either a field or a property, depending on the type of member. If member is of type FieldInfo, this method calls Field to create the MemberExpression. If member is of type PropertyInfo, this method calls Property to create the MemberExpression.

Applies to