Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing command line parameters with Visual Studio C#

How do I set the command line arguments for a console application I am debugging in Visual Studio? I've done this in Eclipse, is there a similar option in Visual Studio?

like image 275
Aadi Droid Avatar asked Jun 25 '11 04:06

Aadi Droid


People also ask

What is command line parameters in C?

They are parameters/arguments supplied to the program when it is invoked. They are used to control program from outside instead of hard coding those values inside the code. argv[argc] is a NULL pointer. argv[0] holds the name of the program.


1 Answers

Command Line Arguments can be set in the Debug tag in the project's Properties window:

enter image description here

Alternatively, there is an option to add StartArguments element to your .csproj.user file:

<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">   <PropertyGroup>     <PublishUrlHistory />     <InstallUrlHistory />     <SupportUrlHistory />     <UpdateUrlHistory />     <BootstrapperUrlHistory />     <ErrorReportUrlHistory />     <FallbackCulture>en-US</FallbackCulture>     <VerifyUploadedFiles>false</VerifyUploadedFiles>   </PropertyGroup>   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">     <StartArguments>Argument1 Argument2</StartArguments>   <<== THIS LINE   </PropertyGroup> </Project> 
like image 179
Alex Aza Avatar answered Sep 24 '22 02:09

Alex Aza