Expression problem: Difference between revisions

Content deleted Content added
Solutions: Avoid redirect
Tags: Mobile edit Mobile web edit
m Replaced AddOneToThree with AddOneToTwo. The former doesn't exist in ExampleTwo.
Line 230:
public static class ExampleThree
{
public static int Evaluate() => ExampleTwo<IPrintExp>.AddOneToThreeAddOneToTwo(new PrintFactory()).Eval();
public static string Print() => ExampleTwo<IPrintExp>.AddOneToThreeAddOneToTwo(new PrintFactory()).Print();
}
</syntaxhighlight>Notice that in ''ExampleThree.Print()'' we are printing an expression that was already compiled in ''ExampleTwo'', we did not need to modify any existing code. Notice also that this is still strongly typed, we do not need reflection or casting. If we would replace the ''PrintFactory()'' with the ''ExpFactory()'' in the ''ExampleThree.Print()'' we would get a compilation error since the ''.Print()'' method does not exist in that context.