Mono Class Library: Mono.CSharp.Evaluator Overview | MembersMono.CSharp.Evaluator.Evaluate Method |
Evaluates and expression or statement and returns the result. [Edit]
|
- input
- The expression to evaluate. [Edit]
The result of computing the expression. [Edit]
Evaluates 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.
[Edit]
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");
Namespace: Mono.CSharp
Assembly: Mono.CSharp (in Mono.CSharp.dll)
Assembly Versions: 2.1.0.0