CSScriptEvaluatorApi.HostApp.EvaluatorSamples.LoadCode_WithInterface C# (CSharp) Метод

LoadCode_WithInterface() публичный Метод

public LoadCode_WithInterface ( ) : void
Результат void
            public void LoadCode_WithInterface()
            {
                // 1 - LoadCode compiles code and returns instance of a first class in the compiled assembly
                // 2 - The script class implements host app interface so the returned object can be type casted into it

                var script = (ICalc) CSScript.Evaluator
                                            .LoadCode(@"using System;
                                                        public class Script : CSScriptEvaluatorApi.ICalc
                                                        {
                                                            public int Sum(int a, int b)
                                                            {
                                                                return a+b;
                                                            }
                                                        }");

                int result = script.Sum(1, 2);
            }