Home > OS >  How can i create console app that takes the values --h or --help c#
How can i create console app that takes the values --h or --help c#

Time:11-11

For example, I want to create a console application, and I need to get help (list of commands, etc.). Can I create this without parsing. For example, I want to open a list of commands on page 2. The command will look like так:.../programm.ехе -- help 2. Indiscriminately. Is that impossible? Maybe c# can do it.

CodePudding user response:

approach without any third party library

using System;
using System.Linq;

public class Program
{
    public static void Main(string[] args)        
    {
        if (args.Any(x => x == "--help" || x == "--h"))
        {
            //get help
        }
    }
}

CodePudding user response:

you could try this package

Install-Package CommandLineParser -Version 2.8.0

with source on github

https://github.com/commandlineparser/commandline

  • Related