Click or drag to resize

IEvaluatorLoadCodeT 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
Syntax
C#
T LoadCode<T>(
	string scriptText,
	params Object[] args
)
where T : class

Parameters

scriptText
Type: SystemString
The C# script text.
args
Type: SystemObject
The non default type T constructor arguments.

Type Parameters

T
The type of the script class instance should be type casted to.

Return Value

Type: T
Aligned to the T interface instance of the class defined in the script.
Examples
The following is the simple example of the interface alignment:
public interface ICalc
{
    int Sum(int a, int b);
}
....
ICalc calc = CSScript.Evaluator
                     .LoadCode<ICalc>(@"using System;
                                        public class Script
                                        {
                                            public int Sum(int a, int b)
                                            {
                                                return a+b;
                                            }
                                        }");
int result = calc.Sum(1, 2);
See Also