 | IEvaluatorLoadCode Method (String, Object) |
Evaluates and loads C# code to the current AppDomain. Returns instance of the first class defined in the code.
Namespace:
CSScriptLib
Assembly:
CSScriptLib (in CSScriptLib.dll) Version: 1.3.2.0
SyntaxObject LoadCode(
string scriptText,
params Object[] args
)
Parameters
- scriptText
- Type: SystemString
The C# script text. - args
- Type: SystemObject
The non default constructor arguments.
Return Value
Type:
ObjectInstance of the class defined in the script.
ExamplesThe following is the simple example of the LoadCode usage:
dynamic script = CSScript.Evaluator
.LoadCode(@"using System;
public class Script
{
public int Sum(int a, int b)
{
return a+b;
}
}");
int result = script.Sum(1, 2);
See Also