When implementing command line flags, should I prefix with a fowardslash (/) or hyphen (-)?

You can (theoretically) use whatever you want, as the parameters are just strings passed to your command-line program.

Windows convention seems to prefer the use of the forward slash ipconfig /all, though there are programs that take a hyphen gacutil -i or even a sort-of environment variable syntax setup SKUUPGRADE=1.

*Nix convention seems to prefer the hyphen -v for single-letter parameters, and double hyphen --verbose for multi-letter parameters.

I tend to prefer hyphens, as they are more OS-agnostic (forward slashes are path delimiters in some OSes) and used in more modern Windows apps (nuget, for example).

Edit:

This would be a good place to recommend a library that does .NET command-line argument parsing: http://commandline.codeplex.com/


Usually it's / on Windows and -/-- on Unix systems for short/long options. But there's no rule for that, so it is actually up to you.


See also Command line options style - POSIX or what?.

The tradition in DOS and Windows is to use a forward slash, as in /a or /extend. The tradition of using -a comes from Unix (and possibly elsewhere).

There's a GNU standard in which a single dash is used for one-letter flags, like -e -d, and they can be merged into -ed (so -ed is equivalent to -e -d). Then many-letter switches need two dashes, as in --extend --display. Sometimes it's only necessary to write as much of the word as is sufficient to deduce what switch is meant, so for example --disp might be a short-hadn for --display if no other switch begins with the letters disp....