Colonel Panic Colonel Panic - 6 months ago 42
C# Question

How to access command line arguments in .csx script?

I'm using

the C# Interactive Compiler to run a
script. How can I access any command line arguments supplied to my script?

csi script.csx 2000

If you're not familiar with csi.exe, here's the usage message:

>csi /?
Microsoft (R) Visual C# Interactive Compiler version
Copyright (C) Microsoft Corporation. All rights reserved.

Usage: csi [option] ... [script-file.csx] [script-argument] ...

Executes script-file.csx if specified, otherwise launches an interactive REPL (Read Eval Print Loop).


Environment.GetCommandLineArgs() returns ["csi", "script.csx", "2000"] for that example.