 | IEvaluatorCreateDelegateT Method (String) |
Wraps C# code fragment into auto-generated class (type name
DynamicClass), evaluates it and loads the class to the current AppDomain.
Returns typed MethodDelegateT for class-less style of invoking.
Namespace:
CSScriptLib
Assembly:
CSScriptLib (in CSScriptLib.dll) Version: 1.3.2.0
SyntaxMethodDelegate<T> CreateDelegate<T>(
string code
)
Parameters
- code
- Type: SystemString
The C# code.
Type Parameters
- T
- The delegate return type.
Return Value
Type:
MethodDelegateT The instance of a typed
MethodDelegateT
Examplesvar product = CSScript.Evaluator
.CreateDelegate<int>(@"int Product(int a, int b)
{
return a * b;
}");
int result = product(3, 2);
See Also