Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to provide help for console application

How to provide help for console application

Scheduled Pinned Locked Moved C#
csharphelptutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zxc89
    wrote on last edited by
    #1

    Hi All, I should write a help for my application in C#.NET at the command prompt. And the format at command prompt should be sample.exe /? or sample.exe/? Plz provide me the code to write this and i should show some help abt what that appliaction do when i press sample.exe/? at command prompt.. Plz HELP!!

    S G Z 3 Replies Last reply
    0
    • Z zxc89

      Hi All, I should write a help for my application in C#.NET at the command prompt. And the format at command prompt should be sample.exe /? or sample.exe/? Plz provide me the code to write this and i should show some help abt what that appliaction do when i press sample.exe/? at command prompt.. Plz HELP!!

      S Offline
      S Offline
      Stefan Troschuetz
      wrote on last edited by
      #2

      Change your main method so it looks similar to the following code snippet:

      static void Main(string[] args)
      {
      if (args.Length != 0)
      {// Evaluate the comand line arguments.
      for (int index = 0; index < args.Length; index++)
      {
      if (args[index] == "/?")
      {
      // Print out help to console
      return;
      }
      }
      // No known command line argument received so show error and preferably help to
      }
      else
      {
      // No command line arguments so run your application as usual

      }
      

      }


      "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

      www.troschuetz.de

      1 Reply Last reply
      0
      • Z zxc89

        Hi All, I should write a help for my application in C#.NET at the command prompt. And the format at command prompt should be sample.exe /? or sample.exe/? Plz provide me the code to write this and i should show some help abt what that appliaction do when i press sample.exe/? at command prompt.. Plz HELP!!

        G Offline
        G Offline
        Green Fuze
        wrote on last edited by
        #3

        the parameters of the Main method are "string[] args". that means that you receive the arguments the user gives you in the command line (arguments = the words after sample.exe). if you want to check if you received /? in the command line, simple check what is the string in args[0]. if(args.Length > 0) // check if there are arguments to prevent exception { if(args[0] == "/?") { // you code } }

        1 Reply Last reply
        0
        • Z zxc89

          Hi All, I should write a help for my application in C#.NET at the command prompt. And the format at command prompt should be sample.exe /? or sample.exe/? Plz provide me the code to write this and i should show some help abt what that appliaction do when i press sample.exe/? at command prompt.. Plz HELP!!

          Z Offline
          Z Offline
          zxc89
          wrote on last edited by
          #4

          Thanks Stefan and Green!!!! Both are working fine!!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups