Click or drag to resize

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
Syntax
C#
Assembly 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: Assembly
The compiled assembly.
Examples
Assembly 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