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

Label() public static method

Creates a LabelExpression representing a label with the given default value.
public static Label ( LabelTarget target, Expression defaultValue ) : LabelExpression
target LabelTarget The which this will be associated with.
defaultValue Expression The value of this when the label is reached through normal control flow.
return LabelExpression
        public static LabelExpression Label(LabelTarget target, Expression defaultValue)
        {
            ValidateGoto(target, ref defaultValue, nameof(target), nameof(defaultValue), type: null);
            return new LabelExpression(target, defaultValue);
        }
    }

Same methods

Expression::Label ( LabelTarget target ) : LabelExpression
Expression::Label ( ) : LabelTarget
Expression::Label ( Type type ) : LabelTarget
Expression::Label ( Type type, string name ) : LabelTarget
Expression::Label ( string name ) : LabelTarget

Usage Example

Exemplo n.º 1
0
        protected override object VisitDoWhile(DoWhile W)
        {
            string name = target.LabelName();

            LinqExprs.LabelTarget begin = LinqExpr.Label("do_" + name + "_begin");
            LinqExprs.LabelTarget end   = LinqExpr.Label("do_" + name + "_end");
            loops.Push(new Loop(LinqExpr.Goto(end), LinqExpr.Goto(begin)));

            target.PushScope();

            // Check the condition, exit if necessary.
            target.Add(LinqExpr.Label(begin));

            // Generate the body target.
            Visit(W.Body);

            // Loop.
            target.Add(LinqExpr.IfThen(target.Compile(W.Condition), LinqExpr.Goto(begin)));

            // Exit label.
            target.Add(LinqExpr.Label(end));

            loops.Pop();
            target.PopScope();
            return(null);
        }
All Usage Examples Of System.Linq.Expressions.Expression::Label
Expression