cs-script Unexpected character "$"

131 views Asked by At

Use cs-script in a console app with

dynamic script = CSScript.LoadCode( @"using System; public class Script { public void SayHello(string name) { Console.WriteLine($""Hello: {name}!""); } }") .CreateObject("*"); script.SayHello("World");

Unexpected character "$" exception throwed. But the following code do well.

            dynamic script = CSScript.Evaluator.LoadCode(
                        @"using System;
                         public class Script
                         {
                             public void SayHello(string name)
                             {
                                Console.WriteLine($""Hello: {name}!"");
                             }
                         }");

        script.SayHello("World");

And i hnow CSScript.Evaluator is more solwer.How can i use the syntax sugar faster?

0

There are 0 answers