Collections

Let's enhance our rocket launcher to support multiple planets.

Collection of Options#

1
public void LaunchRocket([Option(ShortName = "p")] List<string> planets)

This is what help information looks like-

INPUT

1
dotnet example.dll LaunchRocket --help

OUTPUT

1
2
3
4
5
Usage: dotnet example.dll LaunchRocket [options]

Options:
  -h | -? | --help  Show help information
  -p                String (Multiple)

And this is how you pass multiple options:

1
dotnet example.dll LaunchRocket -p mars -p earth -p jupiter

Collection of Arguments#

1
public void LaunchRocket(List<string> planets)

INPUT

1
dotnet example.dll LaunchRocket --help

OUTPUT

1
2
3
4
5
6
7
Usage: dotnet example.dll LaunchRocket [arguments] [options]

Arguments:
  planets  String (Multiple)

Options:
  -h | -? | --help  Show help information

And this is how you pass multiple arguments:

1
dotnet example.dll LaunchRocket mars earth jupiter

Last update: February 22, 2020