CS-Script 3.27.0


Compiler Options

It is possible to pass come compiler  options directly to the code compiler (e.g. Microsoft C# compiler csc.exe) directly from the script code:

//css_co <options>;

options - compiler options as per csc.exe compiler command line interface.

Sample

The following example demonstrates how to define a compiler compiler symbol to be used for the conditional compilation.

 static string code = @"using System;
                        public class Script
                        {
                            public static void Print(string greeting)
                            {
                            #if USE_TIMESTAMP 
                                Console.Write(DateTime.Now.ToString() + "
":"");
                            #endif                                 
                                Console.WriteLine(greeting);
                            }
                         }"
 ...

 //executing code with USE_TIMESTAMP defined
 Print = CSScript.LoadCode("//css_co /define:USE_TIMESTAMP;\n" + code)
                 .GetStaticMethod();