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

TryFinally() public static method

Creates a TryExpression representing a try block with a finally block and no catch statements.
public static TryFinally ( Expression body, Expression @finally ) : TryExpression
body Expression The body of the try block.
@finally Expression
return TryExpression
        public static TryExpression TryFinally(Expression body, Expression @finally)
        {
            return MakeTry(null, body, @finally, fault: null, handlers: null);
        }

Usage Example

Ejemplo n.º 1
0
        public void TryFinally()
        {
            var expected = LinqExpression.TryFinally(
                LinqExpression.Constant(0L),
                LinqExpression.Constant(0L));

            using var g = new GraphEngine.Graph();
            g.LoadFromString(@"
@prefix : <http://example.com/> .

:s
    :tryBody _:zero ;
    :tryFinally _:zero ;
.
_:zero
    :constantValue 0 ;
.
");
            var s = g.GetUriNode(":s");

            var actual = Expression.Parse(s).LinqExpression;

            Console.WriteLine(actual.GetDebugView());

            actual.Should().Be(expected);
        }
All Usage Examples Of System.Linq.Expressions.Expression::TryFinally
Expression