Start Debugging
2023-06-12 Updated 2023-11-05 dotnet-script Edit on GitHub

How to pass arguments to a dotnet script

Learn how to pass arguments to a dotnet script using the -- separator and access them via the Args collection.

When using dotnet script you can pass arguments by specifying them after — (two dashes). You can then access the arguments in the script using the Args collection.

Let’s take an example. Assume we have the following myScript.csx script file:

Console.WriteLine($"Inputs: {string.Join(", ", Args)}");

We can pass parameters to this script as follows:

dotnet script myScript.csx -- "a" "b"

Comments

Sign in with GitHub to comment. Reactions and replies thread back to the comments repo.

< Back