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?
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>
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.
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();
}
}
}
When running independently: the following output:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.