CS-Script 3.20.0


Hello World!

Step-by-step tutorial


The following tutorial shows how to create and execute a simple script.

  1. By using any text editor (eg. Notepad.exe) create file hello.cs that contains the following code:

    using System;
    using System.Windows.Forms; 

    class Script
    {
        static public void Main(string[] args)
        {
            Console.WriteLine("Hello World!" );
            MessageBox.Show("Hello World!");
        }
    }

    Click here to obtain full  listing of hello.cs

  2. Open command prompt. Make sure current directory is the directory where Hello.cs is located.
  3. Execute the following command in command prompt:
 cscs hello

Output

The script will print in command prompt "Hello World!". It will also display "Hello World!" MessageBox.

Code discussion

In this example the script makes the use of FCL class MessageBox that resides in assembly System.Windows.Forms.dll. The script engine dynamically identifies what assemblies are required and loads them at run-time.

Hints and Tips



The easiest way to create the skeleton code for your script is to execute following command in command prompt:

cscs /s > hello.cs

This will instruct script engine to output sample code in a file in current directory (in this case hello.cs).

 

See Also

 CS-Script Tutorials  | Command-line interface