Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumC#expression treesSingle-choice MCQ

You build an expression tree manually and need to invoke it. Why does this code fail, and what fixes it?

var p = Expression.Parameter(typeof(int), "x"); var body = Expression.Add(p, Expression.Constant(1)); // var fn = body(5); // does not work