System.Linq.Expressions.Expression.MemberInit C# (CSharp) Method

MemberInit() public static method

Creates a MemberInitExpression.
/// or is null. The property of an element of does not represent a member of the type that .Type represents.
public static MemberInit ( NewExpression newExpression, IEnumerable bindings ) : MemberInitExpression
newExpression NewExpression A to set the property equal to.
bindings IEnumerable An that contains objects to use to populate the collection.
return MemberInitExpression
        public static MemberInitExpression MemberInit(NewExpression newExpression, IEnumerable<MemberBinding> bindings)
        {
            ContractUtils.RequiresNotNull(newExpression, nameof(newExpression));
            ContractUtils.RequiresNotNull(bindings, nameof(bindings));
            ReadOnlyCollection<MemberBinding> roBindings = bindings.ToReadOnly();
            ValidateMemberInitArgs(newExpression.Type, roBindings);
            return new MemberInitExpression(newExpression, roBindings);
        }
    }

Same methods

Expression::MemberInit ( NewExpression newExpression ) : MemberInitExpression

Usage Example

        public void MemberInit_no_bindings()
        {
            var expression =
                LinqExpression.MemberInit(
                    LinqExpression.New(
                        typeof(SampleClass)));

            ShouldRoundrip(expression);
        }
All Usage Examples Of System.Linq.Expressions.Expression::MemberInit
Expression