Evaluates and expression or statement and returns the result.
Parameters
- input
- The expression to evaluate.
ReturnsThe result of computing the expression.
RemarksEvaluates the input string as a C# expression or statement and returns the value.
This method will throw an exception if there is a syntax error, of if the provided input is not an expression but a statement.
C# Example
// First setup the active using statements: Evaluator.Run ("using System;"); int sum = (int) Evaluator.Evaluate ("1+2"); // A more interesting sample Evaluator.Run ("using System.Linq"); Evaluator.Run ("var numbers = new int [] {1,2,3,4,5};"); // We know the result is an IEnumerator, cast it. IEnumerator even = (IEnumerator) Evaluator.Evaluate ("from x in numbers where (x % 2) == 0 select x");
RequirementsNamespace: Mono.CSharp
Assembly: Mono.CSharp (in Mono.CSharp.dll)
Assembly Versions: 2.1.0.0