Click or drag to resize

IEvaluatorCompileMethod Method

Wraps C# code fragment into auto-generated class (type name DynamicClass) and evaluates it.

This method is a logical equivalent of CompileCode(String, CompileInfo) but is allows you to define your script class by specifying class method instead of whole class declaration.

Namespace:  CSScriptLib
Assembly:  CSScriptLib (in CSScriptLib.dll) Version: 1.3.2.0
Syntax
C#
Assembly CompileMethod(
	string code
)

Parameters

code
Type: SystemString
The C# code.

Return Value

Type: Assembly
The compiled assembly.
Examples
dynamic script = CSScript.Evaluator
                         .CompileMethod(@"int Sum(int a, int b)
                                        {
                                            return a+b;
                                        }")
                         .CreateObject("*");

var result = script.Sum(7, 3);
See Also