 | IEvaluatorCompileCode Method |
Evaluates (compiles) C# code (script). The C# code is a typical C# code containing a single or multiple class definition(s).
Namespace:
CSScriptLib
Assembly:
CSScriptLib (in CSScriptLib.dll) Version: 1.3.2.0
SyntaxAssembly CompileCode(
string scriptText,
CompileInfo info = null
)
Parameters
- scriptText
- Type: SystemString
The C# script text. - info (Optional)
- Type: CSScriptLibCompileInfo
The information about compilation context (e.g. location of the compiler output -
assembly and pdb file).
Return Value
Type:
AssemblyThe compiled assembly.
ExamplesAssembly asm = CSScript.Evaluator
.CompileCode(@"using System;
public class Script
{
public int Sum(int a, int b)
{
return a+b;
}
}");
dynamic script = asm.CreateObject("*");
var result = script.Sum(7, 3);
See Also