473,609 Members | 1,874 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to pass args to console app?

Ron
Hello,

how do you pass args to a console app?

class TestApp
{
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
TestApp testApp = new TestApp();
testApp.Start(a rgs);
}

public void Start(string[] args)
{
...
)
}

Thanks,
Ron
Nov 16 '05 #1
4 21336
hi Ron! :O)
how do you pass args to a console app?


//***
using System;

namespace ConsoleArgsProj ect
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
if (args.Length > 0)
Console.WriteLi ne(args[0]);

Console.WriteLi ne();
Console.WriteLi ne("Press Enter to quit...");
Console.ReadLin e();
}
}
}
//***

now if you actually want to test it (i don't have the exact menu/item names)
:

- open the Project Properties (from the Project menu, last item in the list)
- go in the configuration properties
- select debugging
- you can add a test arguments line in there
- start your app

--
Best Regards
Yanick
Nov 16 '05 #2
In VS.NET, open properties dialog for the project and select the debugging
tree item. Enter the parameters in the Command Line Arguments setting.

At the command prompt, the parameters follow the name of the add name.

"Ron" <an*******@disc ussions.microso ft.com> wrote in message
news:06******** *************** *****@phx.gbl.. .
Hello,

how do you pass args to a console app?

class TestApp
{
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
TestApp testApp = new TestApp();
testApp.Start(a rgs);
}

public void Start(string[] args)
{
...
)
}

Thanks,
Ron

Nov 16 '05 #3
Ron <an*******@disc ussions.microso ft.com> wrote:
how do you pass args to a console app?

class TestApp
{
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
TestApp testApp = new TestApp();
testApp.Start(a rgs);
}

public void Start(string[] args)
{
...
)
}


Not really sure what you mean here - are you talking about creating a
new process with Process.Start? If so, you can use
ProcessStartInf o.Arguments, although you'll need to concatenate all the
arguments together and quote any that have spaces in.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4
Ron
Thanks all for your replies. The solution was to enter
the args in the Debug Command Line in the Project
Properties. That worked! Thanks all for letting me know
about this.

Ron

-----Original Message-----
Hello,

how do you pass args to a console app?

class TestApp
{
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
TestApp testApp = new TestApp();
testApp.Start(a rgs);
}

public void Start(string[] args)
{
...
)
}

Thanks,
Ron
.

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1993
by: john conwell | last post by:
I've got a process engine written in .Net. the user writes a data file and saves it as file type ".xyz". I have a file assiciation set up in the database that when a .xyz file is invoked (double click or called in cmd prompt) it passed to my process engine executable as a cmd line parm. so the process engine gets one argument, which is the path to the .xyz file. this is standard stuff. what i'd like to do is call the .xyz file via the...
3
2313
by: JohnH | last post by:
Does any one now how to create a .net service thet when run from the command line with say a -D argument will run as a console app and be able to output to that console window. The same .exe would start as a normal service wihout the -D argument and require use of the NET START command or other.
2
1323
by: mmaenz | last post by:
Hi, I wrote a Webserver by my own and I would like to support php. But I can't find any information about where php gets the information $_SERVER from. At the moment, I pass all arguments as parameter to the call to php php -f index.php p1=xx p2=xx ... and so on. But the $_SERVER parameter won't work. But with HTTP POST or PUT, (with files for example), I need another way to
1
1018
by: james | last post by:
Does anyone know how to pass a username/password to a DataSource's Delete method? I only see a way to pass those to the Select method. For instance: <asp:DetailsView DataSourceID="ObjectDataSource1" ... /> <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" ... /> Thanks James
1
1405
by: spaulsamin | last post by:
Hi Please let me know how to do the following here, i have property and event in a class, now i want to fire the event from the property when i get value, how to pass args for the below event would you FILL UP THE (?) MARK .
6
4356
by: Joe | last post by:
We pass args to our WinForms app and would like the console to wait until the program ends before returning. For example: C:MyApp.exe -r something This returns even though the process is still running (Task manager, processes). I would like it to wait until the process is done.
3
4818
by: Pia Stevens | last post by:
For a GUI CSharp program I could define command line parameter as well by declaring them in Main(): static void Main(string args) But how do I pass them easily to Form1 ? Or should I declare them in Program.cs and access them from Form1.cs ? Pia
4
7183
by: S Moran | last post by:
vs2005 pro i have a c# windows forms based app that i need the ability to also start from the run line (or command line) and pass args to. how can i do this?
3
10104
by: Alex | last post by:
Hello, I'm wroting a console utility in VB 2005, and I need the ability to pass parameters to the application when the program runs. For example, if my program is called testing.exe, I need to be able to run this: c:\testing.exe c:\test ....and have 'c:\test' passed to the program as a variable. Most of my VB books focus on web forms or windows forms, but not much details on console
0
8139
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8579
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8555
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8232
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8408
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6064
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5524
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4098
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.