Expression::MakeMemberAccess Method (Expression^, MemberInfo^)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Creates a MemberExpression that represents accessing either a field or a property.

Namespace:   System.Linq.Expressions
Assembly:  System.Core (in System.Core.dll)

public:
static MemberExpression^ MakeMemberAccess(
	Expression^ expression,
	MemberInfo^ member
)

Parameters

expression
Type: System.Linq.Expressions::Expression^

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

member
Type: System.Reflection::MemberInfo^

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

Return Value

Type: System.Linq.Expressions::MemberExpression^

The MemberExpression that results from calling the appropriate factory method.

Exception Condition
ArgumentNullException

member is null.

ArgumentException

member does not represent a field or property.

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.

Universal Windows Platform
Available since 8
.NET Framework
Available since 3.5
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: