public void LoadMethodWithInterface()
{
// LoadMethod compiles code and returns instance of a first class
// in the compiled assembly.
// LoadMethod is essentially the same as LoadCode. It just deals not with the
// whole class definition but a single method(s) only. And the rest of the class definition is
// added automatically by CS-Script. The auto-generated class declaration also indicates
// that the class implements ICalc interface. Meaning that it will trigger compile error
// if the set of methods in the script code doesn't implement all interface members.
ICalc script = CSScript.Evaluator
.LoadMethod<ICalc>(
@"int Sum(int a, int b)
{
return a+b;
}");
int result = script.Sum(1, 2);
}