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. C# parameters

C# parameters

Scheduled Pinned Locked Moved C#
questioncsharptutorial
5 Posts 5 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.
  • C Offline
    C Offline
    classy_dog
    wrote on last edited by
    #1

    I am going to write a C# 2010 application as a console application to start with. Eventually I will change the application to compile as a windows application so I do not get the dos pop windows. When this application goes into production, it will be executed by a windows scheduler. My question is the best way to pass parameters to this application. Thus can you show me the following: 1. Code on how to accept values from parameters? 2. When the application runs as an executable, can you show me in code how to pass the values to this executable?

    L P J B 4 Replies Last reply
    0
    • C classy_dog

      I am going to write a C# 2010 application as a console application to start with. Eventually I will change the application to compile as a windows application so I do not get the dos pop windows. When this application goes into production, it will be executed by a windows scheduler. My question is the best way to pass parameters to this application. Thus can you show me the following: 1. Code on how to accept values from parameters? 2. When the application runs as an executable, can you show me in code how to pass the values to this executable?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      How to access command line parameters[^]. To execute a program with parameters you use a command line of the form:

      program_name parameter1 parameter2 "a string parameter with spaces" parametr4 ...

      1 Reply Last reply
      0
      • C classy_dog

        I am going to write a C# 2010 application as a console application to start with. Eventually I will change the application to compile as a windows application so I do not get the dos pop windows. When this application goes into production, it will be executed by a windows scheduler. My question is the best way to pass parameters to this application. Thus can you show me the following: 1. Code on how to accept values from parameters? 2. When the application runs as an executable, can you show me in code how to pass the values to this executable?

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        There are several articles on here regarding parsing command line parameters. Here's one of the more recent ones: Implementing command execution in a console application[^] However, I caution you against expecting a Scheduled Task to be able to run a Windows application or anything that needs user interaction.

        1 Reply Last reply
        0
        • C classy_dog

          I am going to write a C# 2010 application as a console application to start with. Eventually I will change the application to compile as a windows application so I do not get the dos pop windows. When this application goes into production, it will be executed by a windows scheduler. My question is the best way to pass parameters to this application. Thus can you show me the following: 1. Code on how to accept values from parameters? 2. When the application runs as an executable, can you show me in code how to pass the values to this executable?

          J Offline
          J Offline
          jschell
          wrote on last edited by
          #4

          I would suggest that you are also likely to need a way to report on failures. So you might want to investigate that as well.

          1 Reply Last reply
          0
          • C classy_dog

            I am going to write a C# 2010 application as a console application to start with. Eventually I will change the application to compile as a windows application so I do not get the dos pop windows. When this application goes into production, it will be executed by a windows scheduler. My question is the best way to pass parameters to this application. Thus can you show me the following: 1. Code on how to accept values from parameters? 2. When the application runs as an executable, can you show me in code how to pass the values to this executable?

            B Offline
            B Offline
            BC CV
            wrote on last edited by
            #5

            I see the others have you given you plenty to read regarding the parsing of parameters, so I will just add that it would be best to do ONLY the parsing of parameters and possibly writing of the help text in the Console application and put all actual program logic in a dll. That way you can plug any interface you want into your app: console window, windows UI, WPF, Web Service or whatever.

            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