Click or drag to resize

IEvaluatorLoadDelegateT Method

Wraps C# code fragment into auto-generated class (type name DynamicClass), evaluates it and loads the class to the current AppDomain.

Returns instance of T delegate for the first method in the auto-generated class.

Namespace:  CSScriptLib
Assembly:  CSScriptLib (in CSScriptLib.dll) Version: 1.3.2.0
Syntax
C#
T LoadDelegate<T>(
	string code
)
where T : class

Parameters

code
Type: SystemString
The C# code.

Type Parameters

T

[Missing <typeparam name="T"/> documentation for "M:CSScriptLib.IEvaluator.LoadDelegate``1(System.String)"]

Return Value

Type: T
Instance of T delegate.
Examples
var Product = CSScript.Evaluator
                      .LoadDelegate<Func<int, int, int>>(
                                  @"int Product(int a, int b)
                                    {
                                        return a * b;
                                    }");

int result = Product(3, 2);
See Also