Build Configuration and Start Arguments

Will the value entered in "command line arguments" under start options be actually passed on as command line arguments to the executable in the release configuration or is it only a debug thing.

The question is, will it be part of the executable when deployed?

enter image description here

which ends up in the csproj file as shown below

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
    <StartArguments>-blah</StartArguments>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
    <StartArguments>-blah</StartArguments>
  </PropertyGroup>
</Project>

Solution 1:

Command-Line Arguments

The official documentation has a detailed introduction to this.

You can also use Environment.CommandLine or Environment.GetCommandLineArgs to access the command-line arguments from any point in a console or Windows Forms application.

Demo:

enter image description here

using System;

namespace ConsoleApp2 {
    internal class Program {
        static void Main (string[] args) {
            if (args.Length == 0)
                Console.WriteLine("Please enter a numeric argument.");
            else
                foreach (string arg in args)
                    {
                    Console.WriteLine(arg);
                    }
            Console.ReadLine();
            }
        }
    }

enter image description here

exe:

When running independently: the following output:

enter image description here

" They will not be part of your application when you build it and give it to a user to run." Llama is right.